I do not want to match the regex if any formatted number, such as $1,000 appears anywhere before a specific word in the text string.
In this case the word to find is "expungement" - but only if there is NO formatted value before it.
So I would not want to match this string.
this is some initial text $11,000 recommends the expungement more text following
but this would be accepatable
this is some initial text expungement more text following
Thank you.
CodePudding user response:
A pattern you can use is:
^[^\$]*(?!\$[0-9,] )expungement
To explain:
- ^ is start of string
- [^$]* means match any character that is not '$', 0 or more times
- (?!x) means negative lookup for x. If x is found in the line, the match is negated
- \$[0-9,] is a literal dollar sign followed by any combination of digits and commas
- Your desired string at the end