Oracle REGEXP_LIKE not working properly

I tested the regex in Oracle SQL and found something that I could not understand:

-- NO MATCH
SELECT 1 FROM DUAL WHERE REGEXP_LIKE ('Professor Frank', '(^|\s)Prof[^\s]*(\s|$)');

The above does not match, while the following matches:

-- MATCH
SELECT 1 FROM DUAL WHERE REGEXP_LIKE ('Professor Frank', '(^|\s)Prof\S*(\s|$)'); 

In other variants of regular expressions, it will be similar in \bProf[^\s]*\bcomparison with \bProf\S*\band has similar results. Note. There is no \bword boundary in the SQL SQL regular expression .

Question: Why do [^\s]*they \S*work the same in Oracle SQL?

I notice that if I delete (\s|$)at the end, the first regular expression will match.

+4
source share
1 answer

Oracle \s - escape- , NOT ( [.....] [^....] ). , - ] . ; , ] [ ( , ] ), - ( ) - - . ( , [^.....]) , .

. , , . , ^. , " OTHER THAN". . , '[^^]' OTHER THAN ^ ( ^ , - ). ] , , ^ ( ). , OTHER THAN ], '[^]]'.

+3

Source: https://habr.com/ru/post/1656986/


All Articles