mongodb regular expressions matching
i am having these kind of strings
"abc?ref1=app";
"abc?ref1=app&xxxxxxxxxxxxxxxxxxxxxxxxxxx"
where xxxxxxxxxxxxxxx is some string...
i want to write regular ex开发者_如何学Pythonpression which should only match "abc?ref1=app"
types of strings and should not match any other string like "abc?ref1=app&xxxxxxxxxxxxxxxxxxxxxxxxxxx"
..i mean it should only and only match "abc?ref1=app"
type of strings...
i have written some thing like this /abc\?ref1=app/
..but this will also match "abc?ref1=app&xxxxxxxxxxxxxxxxxxxxxxxxxxx"
please tell me how to write regular expression which will only match "abc\?ref1=app"
You do not even need regex here, since mongoDB uses lexographical comparison a simple
{ "myStr" : { $lte : "abc?ref1=app" }
where myStr is your db key
will work
a string like abc?ref1=app&xyz
would be counted as greater than your query.
Add an end-of-line ($) token
abc\?ref1=app$
精彩评论