Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #24093
    spiros
    Participant

    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.

    #24094
    Mr KT
    Participant

    Try this Spiros;

    Find:
    (\{\{grml\r?\n)(.*?\r?\n)(\}\}\n?)(\{\{grml\r?\n)\2(\}\}\n?)

    Replace With:
    \1\2\3

    #24095
    spiros
    Participant

    Thanks :) 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
    #24096
    Mr KT
    Participant

    Sure, 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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.