How do i remove a duplicate line after a particular combination?
-
Let’s say i have this in my notepad:
<path>./gamename1567/gamename1567.cue</path> <image>C:/images/gamename1567/gamename1567.png</image>And i want to do this:
<path>./gamename1567/gamename1567.cue</path> <image>C:/images/gamename1567.png</image>You can see the “gamename” is mentioned twice in the <path> section and i need that as is. But i want the second “gamename” removed if it’s in the <image> section.
There are thousands of lines with different “gamenames” in that text file. So i can’t just replace
“gamename1567.png</image>”
with
“</image>”
Because that will affect only one game in the list. I’m stuck!
-
Hello, @tasos-akrido and All,
Very easy with regular expressions !
-
Open the Replace dialog (
Ctrl + H) -
SEARCH
(?-s)^(\h*<image>C:/images)/.+(/.*\.png</image>) -
REPLACE
\1\2 -
Tick, preferably, the
Wrap aroundoption -
Select the
Regular expressionsearch mode -
Click once on the
Replace Allbutton or several times on theReplacebutton
Voila !
So, for instance, the text :
<path>./gamename1567/gamename1567.cue</path> <image>C:/images/gamename1567/gamename1567.png</image> <path>./gamename37/gamename37.cue</path> <image>C:/images/gamename37/gamename37.png</image> <path>./gamename12345/gamename12345.cue</path> <image>C:/images/gamename12345/gamename12345.png</image>would be changed into :
<path>./gamename1567/gamename1567.cue</path> <image>C:/images/gamename1567.png</image> <path>./gamename37/gamename37.cue</path> <image>C:/images/gamename37.png</image> <path>./gamename12345/gamename12345.cue</path> <image>C:/images/gamename12345.png</image>
In addition this regex S/R can also manage this case :
<path>./gamename1567/aaaaa/bbbbb/ccccc/gamename1567.cue</path> <image>C:/images/gamename1567/aaaaa/bbbbb/ccccc/gamename1567.png</image>And, after replacement, you would get :
<path>./gamename1567/aaaaa/bbbbb/ccccc/gamename1567.cue</path> <image>C:/images/gamename1567.png</image>Nice, isn’t it ?
Best regards
guy038
-
-
Thank you, it works :)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login