问题
How can I use regex to skip the lines with the text added or deleted and match text after the first 12 characters? For example,
1234567890ABTest
ABC4567890ABTestadded
ABC4567890ABTest2
Line 1 would match Test. Line 2 would not match. Line 3 would match Test2. So far, I have
.*(?<!added)(?<!deleted)$
回答1:
^.{12}\KTest(?!(?:added|deleted)\b).*$
You can use \K to skip first 12 characters.See demo.
https://regex101.com/r/fM9lY3/25
回答2:
How about this?
^.{12}(.*)(?<!added)(?<!deleted)$
pattern{X} matches pattern repeated X times.pattern{X,Y} matches pattern repeated X to Y times.pattern{X,} matches pattern at least X.pattern{,Y} matches pattern up to Y times.
回答3:
I am using Notepad++ v5.7
Consider removing everything with the following patterns: ^............, .+added$ and .+deleted$
Everything else is the expected result.
Don't forget to replace in Regular Expression mode.
来源:https://stackoverflow.com/questions/31866961/regex-skip-first-12-characters