I have this 2 lines:
litere bebe litere oana stilou mancare acasa carte literelitere bebe oana stilou mancare acasa carte litere
The word litere is repeated 3 times in the first line, and the same word is repeated 2 times in the second line. Also, the word stilouis present in both lines.
So, I want to find all lines that contain two identical words (litere), but delete up to the second word stilou
1 Answer
My solution is this one:
- Ctrl+H
- Find what:
(litere)(?=.*\1).*(stilou) - Replace with:
LEAVE EMPTY - check Wrap around
- check Regular expression
- DO NOT CHECK
. matches newline - Replace all
and if I want to keep the words litere and stilou, and delete everything bewteen them, I may use this regex:
- Ctrl+H
- Find what:
(litere)(?=.*\1).*(stilou) - Replace with:
\1 \2 - check Wrap around
- check Regular expression
- DO NOT CHECK
. matches newline - Replace all