I’m currently running a query on MongoDB, the field I’m querying contains values such as 123245123 - Johnson-Perez
. If I build a query such as {"name":/123245123/ix}
I get tons of rows and that’s fine, however, as soon as you add the hypens {"name":/123245123 - Johnson-Perez/ix}
I get 0 rows. Do you guys know what could be causing this? I’ve tried replacing the hyphens with [-]
and putting the entire string in double quotes but it didn’t work. I have zero knowledge on regex so I don’t know what could be causing this.
2
Answers
Solved it, I have to escape the whitespaces as well as the hyphen and the dots.
Try: