Reputation: 11
There is a question like this here asking about the first occurrence of "1" in each line, but in EditPad it doesn't work at all, even when I use the Multi-Line Search Panel.
I have Regex on, Highlight All on. All other functions are off.
I guess that ^[^1\n\r]*(1) is one step towards the real "first occurrence", but it is not there yet.
For example, I have the number 5215681571
And I want to highlight only the first "1" in the line. The expression ^[^1\n\r]*(1) will highlight 521 which is not desirable.
I have tried also ^(^.*[^1])1 which finds every line that contains 1 and highlights everything from start until the last "1".
In stackoverflow, I have seen countless suggestions on how to achieve the first occurrence, but none of them works in EditPad. Any idea, please?
Upvotes: 1
Views: 183
Reputation: 163362
In the patterns that you tried, you use a capture group, preceded by a match.
If this is the tool the regex engine is indicated as JGsoft V2
which supports using \K
to forget what is matched so far.
Matching all except 1 or a carriage return or a newline:
^[^\r\n1]*\K1
Or matching all except 1 and vertical whitespaces \v
^[^\v1]*\K1
Upvotes: 1
Reputation: 41838
In addition to what @The fourth bird suggested, EditPad's JGSoft engine supports infinite lookbehind, which lets you do this (tested in EPP Pro 8.2.4):
(?<=^[^1\r\n]*)1
To catch any kind of weird unicode line breaks you can also use [^\p{Zl}]
in place of [^\r\n]
, yielding these two alternate versions:
^[^\p{Zl}1]*\K1
or
(?<=^[^1\p{Zl}]*)1
Upvotes: 1