1

Inside Mongodb I would like to search with regex. For example I would like to make a query to returns all of these:

"ab-cd/ef" 
"ab/cd.ef" 
"abcdef"

I have created that query

db.getCollection('collection').find({detail:{$regex:"ab.*.cd.*.ef"}}

but the problem is that it cannot find "abcdef"

1 Answer 1

1

Remove the trailing .s so that it's just:

db.getCollection('collection').find({detail: {$regex: "ab.*cd.*ef"}}

With the trailing .s it's requiring at least one char between each group.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.