Replacing Oracle regex for negative lookup / lookbehind

I am writing an Oracle PL / SQL procedure that looks for possible customer numbers in a column. Customer numbers are 7 digits long and can be prefixed or suffixed with any number of characters. However, some of the values ​​contain> 7-digit numbers , and in these cases I want to ignore them. Therefore, β€œA / C 1234567” and β€œCust1234567B” should return a match for customer number 1234567 , but β€œ 01234567 ” and β€œ 123456789 ” should not.

I use \d{7} , but this returns a match on all examples, so I'm looking for something similar to (?<!\d)\d{7}(?!\d) - but negative lookahead and lookbehind are not supported . Any suggestions?

+4
source share
2 answers

Without statements and views available, you can try

 (^|\D)\d{7}(\D|$) 

http://sqlfiddle.com/#!4/d41d8/12114/0

+5
source

I ran into the same problem that I just did

 NOT regexp_like(<pattern_you_want_to_negate>) 
+2
source

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


All Articles