TextPad's regular expression handling of end-of-line via $ seems to be broken (or changed). I updated to the latest versions (9.9.6 and 8.23.6) and I still have the issue.
The problem is it seems to blow passed \n on a non-match. For example, if I am looking to replace all lines ending with X, it will match that line plus the lines before it that DON'T end in X. So:
regex: ^[^X]*X$
Text:
11111X
22222
33333X
44444
The first match is "11111X' and the 2nd is "22222" and "33333X". It appears to blow right passed the end-of-line character(s).
If I tried to inhibit that by putting \n in the character set, that seems to work OK. Has the behavior been changed or is it a bug?
Thanks,
DrX
Regex Issue with EOLN
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Re: Regex Issue with EOLN
What you experience is actually the wanted behavior by a regex engine.https://www.regular-expressions.info/charclass.html#negated wrote:Unlike the dot, negated character classes also match (invisible) line break characters. If you don’t want a negated character class to match line breaks, you need to include the line break characters in the class. [^0-9\r\n] matches any character that is not a digit, carriage return, or line feed.
Also I can reproduce your issue with TextPad 8.4.2 from 2020: your 2nd and 3rd line are also one match. Which means: TextPad's regex behavior has not changed within 6 years between 8.4.2 and 8.23.6.