- AuthorPosts
- January 1, 2019 at 2:27 am #24093spirosParticipant
I use this: (\{\{grml\n.*?\n\}\}\n)
To match the first group:
{{grml
|mltxt=Α [[τρέχω]]<br />[[λαμβάνω]] [[μαζί]] ή έλα.
}}
{{grml
|mltxt=Α [[τρέχω]]<br />[[λαμβάνω]] [[μαζί]] ή έλα.
}}How can I make the regex match the 2nd group too, if their content is the same (in order to eliminate duplicate entries like this)? I tried adding \1 in find but did not work.
January 1, 2019 at 7:58 am #24094Mr KTParticipantTry this Spiros;
Find:
(\{\{grml\r?\n)(.*?\r?\n)(\}\}\n?)(\{\{grml\r?\n)\2(\}\}\n?)Replace With:
\1\2\3January 1, 2019 at 8:09 am #24095spirosParticipantThanks :) For some reason it did not work for me.
I tried the one below, which worked in Notepad++ (And PCRE, as ultimately I wanted to run it on a MariaDB database).(\{\{grml\n.*?\n\}\}\n)\1 \1
January 1, 2019 at 8:25 am #24096Mr KTParticipantSure, just be aware that your last version, (\{\{grml\n.*?\n\}\}\n)\1 won’t match if a duplicate is the last line in the file (if there is no final “\n”). Otherwise it will do the job just fine.
This should work in Notepad++/Emeditor (issue is with the way newline is represented, so “\r?\n” should handle this), and also work if the last line is the dupe.
(\{\{grml\r?\n)(.*?\r?\n)(\}\}\r?\n?)(\{\{grml\r?\n)\2(\}\}\r?\n?)
\1\2\3 - AuthorPosts
- You must be logged in to reply to this topic.