java - Mongo can't find document while using regex with backslash and & character -
i'm using java mongo find document in database. i'm using following code:
criteria.where(fieldname).regex("astronomy \& astrophysics", "i")
this string "astronomy \& astrophysics" changed in query to:
astronomy \\& astrophysics
there documents in database have fieldname fields equal to:
astronomy \& astrophysics
but document isn't returned
what java code should use make code work?
for work have escape backslash \
your new code should this
criteria.where(fieldname).regex("astronomy \\& astrophysics", "i")
see demo here https://regex101.com/r/uj0vd4/11
Comments
Post a Comment