James
James

Reputation: 3184

Regex - Skip first 12 characters

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)$

Upvotes: 3

Views: 25546

Answers (3)

vks
vks

Reputation: 67998

^.{12}\KTest(?!(?:added|deleted)\b).*$

You can use \K to skip first 12 characters.See demo.

https://regex101.com/r/fM9lY3/25

Upvotes: 10

w35l3y
w35l3y

Reputation: 8783

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.

Upvotes: 0

Alyssa Haroldsen
Alyssa Haroldsen

Reputation: 3731

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.

Upvotes: 1

Related Questions