Search code examples
regexreplacenotepad++notepad

Notepad++ Replacing Text Between Two Strings


I'm trying to remove strings between two words in .po file. Tried few things already fish search&replace but so far it didn't go well.

Example of text:

msgctxt ",0CAEC952474D390ED3EACB814418BE9A"
msgid ""
"Captain Thorus needs \r\n"
"all men attend him"
msgstr ""
"Kapitan Thorus potrzebuje \r\n"
"wszystkich przy sobie"

And I would like to replace:

msgid ""
"Captain Thorus needs \r\n"
"all men attend him"

With just blank field \n. But the thing is that msgid "" can contain custom texts like msgid "some_text" and text below also are different.

Is there a way to just replace everything between msgctxt "" and msgstr "" to blank?


Solution

  • try:

    (?s)msgctxt.*?\"$\K.*?(?=msgstr)
    

    The above regex resulted in after substitution:

    msgctxt ",0CAEC952474D390ED3EACB814418BE9A"
    msgstr ""
    "Kapitan Thorus potrzebuje \r\n"
    "wszystkich przy sobie"