I'm writing a PL/SQL Oracle procedure that looks for possible customer numbers in a column. Customer numbers are 7 digits long, and could 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. So "A/C 1234567" and "Cust1234567B" should return a match for customer number 1234567, but "01234567" and "123456789" should not.
I am using \d{7}
but this is returning a match on all the examples, so am looking for something similar to (?<!\d)\d{7}(?!\d)
- but negative lookahead and lookbehind aren't supported. Any suggestions?
Without lookahed and lookbehind assertions available you could try
(^|\D)\d{7}(\D|$)
http://sqlfiddle.com/#!4/d41d8/12114/0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With