Am I setting the variables incorrectly or something? I did see this post about a very similar issue (seems like it was never resolved), as well as this issue related to regex variables not working with the Go client. Is it possible that the JavaScript client has a similar problem with regex variables?
The regexp is wrong. You’re using Javascript flavoured regular expressions. Dgraph supports proper regular expressions.
There shouldn’t be / in the regex. When you are using Ratel, / serves as a delimiter for the regular expression, much like " serves as a delimiter for strings. You’re passing in the regular expression as a string when calling via JS, not as a regular expression (object).
To construct your regex string, the following JS would work:
`.*${name}.*`
p/s: Don’t write .*. It’s a bad habit. Don’t write .+ either. Also a bad habit.
pp/s: proper regular expression doesn’t have name interpolation/variable or named capture. Those are called PCRE (Perl Compatible Regular Expressions), which are NOT Regular Expressions. I don’t think they’re even regular. Go only supports regular expressions.
ppp/s: yes, I am a stickler for formal language hierarchies.
You’re using Javascript flavoured regular expressions.
Yes, and the argument could be made that JavaScript regular expressions should be supported when one is using the official Dgraph JavaScript client. Nevertheless, I’ll switch to what Dgraph supports, but this doesn’t help me do that:
Dgraph supports proper regular expressions.
Could you please link me to something that documents the proper regular expressions supported by Dgraph so I don’t use the wrong syntax?
In particular, I’m wondering how to ensure that my match is case insensitive. In JavaScript, I would use the i flag after the closing / to achieve this (which works in Ratel):
I was able to get this resolved, but it looks like the / characters are required. If I remove them, I get an error from Dgraph:
Error: 2 UNKNOWN: Unexpected error while parsing regex arg: ife
at Object.callErrorFromStatus (node_modules/@grpc/grpc-js/src/call.ts:81:24)
at Object.onReceiveStatus (node_modules/@grpc/grpc-js/src/client.ts:334:36)
at Object.onReceiveStatus (node_modules/@grpc/grpc-js/src/client-interceptors.ts:434:34)
at Object.onReceiveStatus (node_modules/@grpc/grpc-js/src/client-interceptors.ts:397:48)