Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I match a full string in FaunaDB using ContainsStrRegex?

I’m trying to match a full string of digits using the following expression in Fauna Query Language:

q.ContainsStrRegex("123", "^\d*$")

This returns false. Just "\d*$" seems to work so I would imagine there’s a different -1th match pattern. What do I need to do?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Your host language, which looks like JavaScript, is doing string parsing before the pattern makes it into the ContainsStrRegex function. "\d" means "make a string with this escaped ‘d’", which is just "d".

You need to escape the backslash to get it into the string, and subsequently into the function.

q.ContainsStrRegex("123", "^\\d*$")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading