> Ruby regular expressions always have BSON regular expressions' equivalent of 'm' flag on.
While this is true, having /m on changes the meaning of . to include newlines.
The principal difference between Ruby and PCRE regular expressions is the meaning of ^ and $ anchors, which in Ruby is not configurable and they always refer to beginning/end of line while in PCRE depending on whether regexp is multiline they refer to beginning/end of line or input.
This ticket covers changing our documentation to:
- Clearly describe this difference between Ruby and PCRE/MongoDB regexps.
- Emphasize that compatibility can be attained by using \A and \z in regexps instead of ^ and $. mongo shell supports \A and \z anchors. But, see the next point for /m.
- Come up with a way to deal with the fact that currently bson-ruby does add /m by default. Hopefully a way that does not involve code changes.
In a later version of bson-ruby, we could consider dropping /m by default and instead requiring that users use \A and \z in their regular expressions to match the expected behavior of ^ and $ in PCRE/MQL.