I have been trying to create a regular expression for the following problem:
A) PAR B) 1234
given strings A and B above, i want to find all matches where those values occur in order regardless of white space, etc with the following important rules:
- both strings A and B cannot exist as a substring to another larger string
- the given string B must occur after A
- the given string B must occur by itself and not be a part of another number
here are some example potential matches:
- PAR1234
- PAR 1234
- PAR 5678, 1234
- PAR 9991234999, 1234
- PAR !@#-= 1234
- PAR1234-122
- PAR#1234-233
- ANY TEXT PAR#1234-233
however, the following should not match:
- PART 1234 - PAR is substring of PART
- APART 1234 - PAR is substring of APART
- PAR 1234999 - 1234 is substring of 1234999
- PAR 9991234 - 1234 is substring of 9991234
- PAR 9991234999 - 1234 is substring of 9991234999
- 1234 PAR - 1234 occurs before PAR
unfortunately, i am trying to do this using REGEXP_LIKE in oracle and there is no \b
i tried
\W*PAR\W*1234
but that won't match #3 in the potential matches above. so ive attempted many variations that will work for some but not all.
i was wondering if there is an expression that could capture what i am trying to accomplish. any help would be greatly appreciated.
thanks.