Regex - Skip first 12 characters

大城市里の小女人 提交于 2020-01-05 02:58:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!