Orient-db regex modifiers

北战南征 提交于 2019-12-10 20:35:17

问题


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.


回答1:


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.




回答2:


Unfortunately there is no way to specify modifiers for regex in matches operator.

For now the good solution would be to create a custom function, where you can use whole power of JS regexps.

But we definitely should add ability to specify modifiers in MATCHES, could you create a feature request?



来源:https://stackoverflow.com/questions/24164411/orient-db-regex-modifiers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!