having this
“area”: { “$regex”: “17)” } }
I tried escape the ) as “17)” and also tried with “17\)” both not working
is there something I missing?
Regards
having this
“area”: { “$regex”: “17)” } }
I tried escape the ) as “17)” and also tried with “17\)” both not working
is there something I missing?
Regards
You would need to escape the escape character for example, I have two documents in my test collection:
curl --location --request POST 'https://data.mongodb-api.com/app/data-xxx/endpoint/data/beta/action/find' \
--header 'Content-Type: application/json' \
--header 'Access-Control-Request-Headers: *' \
--header 'api-key: xxx' \
--data-raw '{
"collection":"test",
"database":"test",
"dataSource":"rs0"
}'
{"documents":[{"_id":0,"area":"17"},{"_id":1,"area":"17)"}]}
and we can select the one with the bracket using regex:
curl --location --request POST 'https://data.mongodb-api.com/app/data-xxx/endpoint/data/beta/action/find' \
--header 'Content-Type: application/json' \
--header 'Access-Control-Request-Headers: *' \
--header 'api-key: xxx' \
--data-raw '{
"collection":"test",
"database":"test",
"dataSource":"rs0",
"filter": {"area": {"$regex":"17\\)"}}
}'
{"documents":[{"_id":1,"area":"17)"}]}
Please note the {"$regex": "17\\)"}
in the filter above.
Best regards
Kevin
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.