regex - Oracle regular expression replacement for negative lookahead/lookbehind that doesn't consume a character -
i'm looking better answer similar problem post "oracle regular expression replacement negative lookahead/lookbehind"
my problem find numbers of 8 digit coming after keyword.
must match: ref12345678 ref:12345678 ref text or short 23 num 12345678
not match: ref 123456789 ref 123456789
'(ref)(.*?)(\d{8})(\w|$)'; # matches 9 digits: ref 123456789 '(ref)(.*?)\d(\d{8})(\w|$)'; # won't match ref12345678
\d suggested solution in existing post way avoid .*? matching 1st digit of 9, if there no non-digits left won't work. (in ref12345678 f in ref used already).
'(ref)(.*?)(?<!\d)(\d{8})(\w|$)'
works wonderfully in perl, not oracle, doesn't support negative lookbehind.
how can zero-width assertion either non-digit comes before number, or .* did not end digit? (using \d? won't work.)
any suggestions please?
i think you're looking for:
(ref)(.*?\d)?(\d{8})(\w|$)
this says, if there characters between ref
, 8 digits, last 1 must non-digit.
Comments
Post a Comment