In my collection following query returns some result:
db.c.find({t:/a/})
But below query (and any other regex that has uXXXX
) returns no result:
db.c.find({t:/u0041/})
What is wrong?
See Question&Answers more detail:osIn my collection following query returns some result:
db.c.find({t:/a/})
But below query (and any other regex that has uXXXX
) returns no result:
db.c.find({t:/u0041/})
What is wrong?
See Question&Answers more detail:osThe reason for this is that according to the documentation
MongoDB uses PCRE for regular expressions.
However the PCRE documentation says
The following Perl escape sequences are not supported: l, u, L, U, and N when followed by a character name or Unicode value. (N on its own, matching a non-newline character, is supported.) In fact these are implemented by Perl's general string-handling and are not part of its pattern matching engine. If any of these are encountered by PCRE, an error is generated by default. However, if the PCRE_JAVASCRIPT_COMPAT option is set, U and u are interpreted as JavaScript interprets them.
That said, this SO question may be of some help.