Search code examples
regexnotepad++po

RegEx: Replace lines that start with "msgctxt" with content that is in between quotation marks of those strings


I have several big files with several entries like these:

msgctxt "#. client error message"
msgctxt "#. 0 = ID"
#: Some more text
msgid ""
"Could not activate\n"
"Connection lost?"
msgstr ""
"Some other text"
"Even more other text"

Now, ideally, I would like all of the lines that start with "msgctxt" to be replaced with the content that is in between the quotation marks of those strings:

#. client error message
#. 0 = ID
#: Some more text
msgid ""
"Could not activate\n"
"Connection lost?"
msgstr ""
"Some other text"
"Even more other text"

Some entries don't have any "msgctxt", others have only one or several.

Is there a way to do this with Regular Expressions in Notepad++?


Solution

  • My guess is that a simple expression such as,

    msgctxt\s+"(.+)"
    

    being replaced by $1 would simply suffice.

    Demo