Filter by Regular expression within a list

I want to modify an existing exact match query that takes a list parameter for filtering

Is there a mechanism to filter based on any of a list of regular expressions:
Something like
WHERE obj.text IN [‘^abc.*’,’.*def$’,’exact’]

do you have to do it as a list rather than one more complicated regex?
otherwise maybe UNWIND might help you here?

Thanks for your reply.
Elements come at runtime from different sources (it's a graphql query) so List would be the easiest, compared to a complicated regex, but will look into other options.

Hello @dptuck and welcome to the Neo4j community :slight_smile:

You can use the any() function to match your regular expressions:

WHERE any(regex IN ['^abc.*', '.*def$', 'exact'] WHERE obj.text =~ regex)

Regards,
Cobra

1 Like

Thank you, Cobra.
This works perfectly.

1 Like