Reputation: 3735
If [\s\d]*
means: repeat matching space-character or digit. What would be the syntax for ignoring the entire line if there suddenly is a "-"
character?
Like in this example https://regex101.com/r/eP1kG1/1 The last line should not match!
.*\bAPPLE.*\bPIE[\s\d]*
SWEET APPLE 1 - PIE 2
SWEET APPLE 1 - PIE 2 IS GOOD
SWEET APPLE 1 - PIE3
SWEET APPLE 1 - PIE 1-3 IS GOOD
Only the last line should not match, meaning: When there is a "-" after PIE it should fail.
Also this is for sql, and not possible to use look-ahead/behind
Upvotes: 0
Views: 142
Reputation: 626794
As I mentioned in my comment, look-aheads usually consume much more computing power. I'd suggest the following regex:
^.*\bAPPLE.*\bPIE[\s\d]*[^-]*$
It just requires all characters after [\s\d]*
to be non-hyphens. Anchors - ^
and $
- make sure we only check the whole string.
See demo.
Upvotes: 1
Reputation: 3446
Is this what you want? Just checking to make sure PIE[\s\d]*
isn't followed by a -
on the line:
(?!.*PIE[\s\d]*-).*\bAPPLE.*\bPIE[\s\d]*
Upvotes: 1