Cannot filter by regexp

Hi, I am facing an error when I’m trying to filter nodes by regex.

query { 
    queryTest(filter: { path: { regexp: "/^//PROD.*/" }}) 

Actually, this regex used to work in DQL, but is not with graphQL.

Below is my the node in schema.

type Test {
    id: String! @id
    port: String! @search(by: [exact])
    path: String! @search(by: [regexp, exact])

I tried to escape, and other things, but didn’t works.
I got the error:
“message”: “Dgraph query failed because Dgraph execution failed because line 2 column 72: Expected comma or language but got: PROD.”

1 Like

I believe escape to be the cuplrit IMO. What escape patterns did you use? I think you will need a double escape like regexp: "/^\\/\\/PROD.*/"

And just to be sure, make sure you are using " (straight quotes) and not or (angled quotes), but that is probably just your text formatter in this question.

P.S. you can format your code blocks by putting ``` on a blank line before and after the block :wink:


Its works.
Thanks a lot.