Search code examples
sqlregexorientdb

Orient-db regex modifiers


I'm working with orient-db database, and I've issues with regex pattern matching. I really need case-insensitive modifier to be present in the request, but somehow it doesn't work as I'm expecting.

Query:

select from UserAccounts where email MATCHES '^ther.*'

Returns as expected matches in lowercase.

Whenever I try to add a modifier, outside delimiters i.e.

select from UserAccounts where email MATCHES '\^ther.*\i'

I get an empty collection. Actually the query returns an empty collection whenever delimiters are present.

If there is no way to attach modifiers I could probably replace each 'alpha' char to an expression in square brackets i.e.

select from UserAccounts where email MATCHES "^[tT][hH][eE][rR].*"

But I'm not really happy with this solution.


Solution

  • Using the Java case-insensitive regex modifier (from Pattern's special constructs) works in OrientDB 1.7.9 - for your example:

    select from UserAccounts where email MATCHES '(?i)^ther.*'
    

    (See also: Pattern - Special Constructs)

    I've added a comment to the corresponding OrientDB issue as well.