Match everything but exclude words - notepad ++
Input:
start
some
T1
random
T2
text
T3
end
it should look like this:
start
T1
T2
T3
end
I tried to use
>(?<=start)[\S\s]*?(?=end)
to combine everything between the beginning and the end
and exclude T1 T2 T3 with:
^(?!T\d)
Is it possible to combine them into a single regex that can be inserted into notepad ++ for people unfamiliar with writing code to do it in a few passes?
source to share
You can use this regex:
Find: ^(?!T\d|start).*\R(?=(^(?!start$).*\R)*end$)
Replace: (empty) matches newlines: None
.
Click "Replace All"
These assumptions are made:
start
And delimitersend
must be the only text on their lines (not---start
orstart ///
),- They must appear in pairs in the correct order (first
start
and thenend
) - They don't have to be nested, so
start
there can't be another onestart
after you have itend
.
Looking ahead makes this a rather inefficient regex, as on every match it needs to check the text again, which follows until the next one end
.
source to share