Community
    • Login

    Replace multiple characters only in lines starting with specific words

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    replacetransliterateregex
    8 Posts 3 Posters 2.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • KubaK
      Kuba
      last edited by Kuba

      Hi
      I’m quite new to this community forum but I’m fairly long-time user of Notepad++. I have a problem with batch replacing multiple characters to other characters (transliteration?). After extensive but not 100% efficient research over many topics in Help Wanted section I finally got to the point where the letters are beautifully replaced within the whole text. I got stuck on the problem of pointing the specific lines only in which these replacement should take place. I would like that only lines staring with:
      #MP3:
      #COVER:
      #BACKGROUND:
      #VIDEO:
      were taken under account.
      The file contains other lines starting with “#” and those lines should stay unchanged.

      Now I’m doing it like this: I use search & replace tool:

      S:
      (?-i)(ę)|(ć)|(ó)|(ł)|(ą)|(ć)|(ś)|(ż)|(ń)|(ź)|(Ł)|(Ć)|(Ś)|(Ź)|(Ż)

      R:
      (?1e)(?2c)(?3o)(?4l)(?5a)(?6c)(?7s)(?8z)(?9n)(?10z)(?11L)(?12C)(?13S)(?14Z)(?15Z)

      I’m pretty sure the solution is trivial, but I just can’t get it right. Any help would be appreciated.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Kuba
        last edited by

        @Kuba,

        I’m pretty sure the solution is trivial

        Not by my definition of trivial. However, with a little thought, it appears to fit within our regex guru @guy038’s generic regular expression for changing data, but only when between certain start and end conditions

        In your case, the start condition is a line that does not start with #, and the end condition is the end of line (or end of file)

        For simplicity, I am going to use a shortened version of your search/replace, with only the first three terms; you should be able to expand my result back to your full expressions

        Translating that into regex:

        • FR = (ę)|(ć)|(ó) – I took out your (?-i) because that happens to be embedded in the wrapper around FR in the generic expression
        • RR = (?1e)(?2c)(?3o)
        • BSR = ^(?!#) = this says “start of the line that isn’t followed by #”
        • ESR = (?:\R|\Z) = this says “end of line or end of file”

        Plugging those into the generic

        • FIND = (?-i:^(?!#)|(?!\A)\G)(?s:(?!(?:\R|\Z)).)*?\K(?-i:(ę)|(ć)|(ó))
        • REPLACE = (?1e)(?2c)(?3o)
        • SEARCH MODE = regular expression

        So this:

        linę óne ćontains
        # so dóęs linę twó, but commented out
        linę thręę will change, tóó
        

        is transformed into this:

        line one contains
        # so dóęs linę twó, but commented out
        line three will change, too
        
        1 Reply Last reply Reply Quote 0
        • KubaK
          Kuba
          last edited by Kuba

          Well… Your solution doesn’t seem to be trivial after all :)

          But the proposed solution still has one unsolved problem. I 'm afraid you missed the part where I wrote that there are other lines starting with # which I want to remain unchanged… So the FIND code must include some sort of OR structure… or some other way to exclude unnecessary lines/select only those four, starting with #MP3, #COVER, #BACKGROUND, #VIDEO.

          Below is the sample file structure. It’s karaoke lyrics file that need to have names of files changed - but only in those four above mentioned lines.

          #TITLE:Nie Mogę Cię Zapomnieć
          #ARTIST:Agnieszka Chylińska
          #LANGUAGE:Polish
          #GENRE:Pop
          #YEAR:2009
          #CREATOR:davidus01
          #MP3:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć.mp3
          #COVER:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć [CO].jpg
          #BACKGROUND:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć [BG].jpg
          #VIDEO:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć.mp4
          #VIDEOGAP:1
          #BPM:126,37
          #GAP:53880
          : 0 2 10 Ko
          : 2 2 7 chać
          : 4 4 7 ci
          : 8 2 5 ę,
          12
          : 16 2 -2 to
          : 18 2 -2 mieć
          : 20 2 3 w ser
          : 22 2 5 cu
          : 24 4 5 cierń
          30
          : 34 2 -2 i
          …

          I was also thinking about the dot before the file extension, but I’m afraid that such dot can be present in other lines starting with # in other files…

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Kuba
            last edited by PeterJones

            @Kuba ,

            As always when asking search/replace questions, giving example data that includes both BEFORE and AFTER data will prevent misunderstandings, because I could have then seen that my translation didn’t match your expected output, and I would have re-read the problem and experimented until I figured it out. You haven’t provided the AFTER data, so only you will be able to know if my solution works or not.

            So instead of the rule where the start condition is “a line that does not start with #”, what I believe to be the correct rule would be “a line that starts with #MP3: or #COVER: or #BACKGROUND: or #VIDEO:”, which is (#MP3:|#COVER:|#BACKGROUND:|#VIDEO:). Since the # and : are common to all, in regex, that can be condensed down into #(?:MP3|COVER|BACKGROUND|VIDEO): as your BSR, resulting in SEARCH = (?-i:#(MP3|COVER|BACKGROUND|VIDEO):|(?!\A)\G)(?s:(?!(?:\R|\Z)).)*?\K(?-i:(ę)|(ć)|(ó)) for my shortened FR.

            If I add ęćółąćśżńźŁĆŚŹŻ to the end of each of your lines to make sure that all lines have potential matches, and still do my reduced search with the modified BSR, it will find:
            322389ce-4633-4c17-a1a6-791f5eb442a0-image.png

            to become:

            #TITLE:Nie Mogę Cię Zapomnieć ęćółąćśżńźŁĆŚŹŻ
            #ARTIST:Agnieszka Chylińska ęćółąćśżńźŁĆŚŹŻ
            #LANGUAGE:Polish ęćółąćśżńźŁĆŚŹŻ
            #GENRE:Pop ęćółąćśżńźŁĆŚŹŻ
            #YEAR:2009 ęćółąćśżńźŁĆŚŹŻ
            #CREATOR:davidus01 ęćółąćśżńźŁĆŚŹŻ
            #MP3:Agnieszka Chylińska - Nie Moge Cie Zapomniec.mp3 ecołącśżńźŁĆŚŹŻ
            #COVER:Agnieszka Chylińska - Nie Moge Cie Zapomniec [CO].jpg ecołącśżńźŁĆŚŹŻ
            #BACKGROUND:Agnieszka Chylińska - Nie Moge Cie Zapomniec [BG].jpg ecołącśżńźŁĆŚŹŻ
            #VIDEO:Agnieszka Chylińska - Nie Moge Cie Zapomniec.mp4 ecołącśżńźŁĆŚŹŻ
            #VIDEOGAP:1 ęćółąćśżńźŁĆŚŹŻ
            #BPM:126,37 ęćółąćśżńźŁĆŚŹŻ
            #GAP:53880 ęćółąćśżńźŁĆŚŹŻ
            

            You searched the forum for regex advice, which means you’ve had ample opportunity to see the following; but it would be good for you to read it now and take it to heart:

            ----

            Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the </> toolbar button or manual Markdown syntax. To make regex in red (and so they keep their special characters like *), use backticks, like `^.*?blah.*?\z`. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

            –
            EDIT after post: added ?: to the or-group, so it doesn’t change the capture-group numbering, and fixed the “after” data.

            1 Reply Last reply Reply Quote 1
            • guy038G
              guy038
              last edited by guy038

              Hello, @kuba, @peterjones, and All,

              Hi, Peter, we can use a simplification when the ESR is the end of current lines

              Indeed, as the dot meta-character does not match EOL characters, when the (?-s) modifier is used, the regex engine will necessarily advances two positions, after \r\n to match something else. And, because of the \G assertion it will force the regex engine to jump to an other line, downwards, in order to search, either, for an other literal string #MP3:, #COVER: , #BACKGROUND: or #VIDEO: again !

              In other words, the distinction, between standard and EOL characters, creates an implicit ESR region :-))


              So this regex S/R can be expressed as :

              SEARCH (?-si:#(MP3|COVER|BACKGROUND|VIDEO):|(?!\A)\G).*?\K(?:(ę)|(ć)|(ó)|(ł)|(ą)|(ć)|(ś)|(ż)|(ń)|(ź)|(Ł)|(Ć)|(Ś)|(Ź)|(Ż))

              REPLACE (?1e)(?2c)(?3o)(?4l)(?5a)(?6c)(?7s)(?8z)(?9n)(?10z)(?11L)(?12C)(?13S)(?14Z)(?15Z)


              Tested against this initial text, with a last #MP3: line, without any final line-break

              #TITLE:Nie Mogę Cię Zapomnieć---ęćółąćśżńźŁĆŚŹŻ
              #ARTIST:Agnieszka Chylińska---ęćółąćśżńźŁĆŚŹŻ
              #LANGUAGE:Polish---ęćółąćśżńźŁĆŚŹŻ
              #GENRE:Pop---ęćółąćśżńźŁĆŚŹŻ
              #YEAR:2009---ęćółąćśżńźŁĆŚŹŻ
              #CREATOR:davidus01---ęćółąćśżńźŁĆŚŹŻ
              #MP3:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć.mp3---ęćółąćśżńźŁĆŚŹŻ
              #COVER:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć [CO].jpg---ęćółąćśżńźŁĆŚŹŻ
              #BACKGROUND:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć [BG].jpg---ęćółąćśżńźŁĆŚŹŻ
              #VIDEO:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć.mp4---ęćółąćśżńźŁĆŚŹŻ
              #VIDEOGAP:1---ęćółąćśżńźŁĆŚŹŻ
              #BPM:126,37---ęćółąćśżńźŁĆŚŹŻ
              #GAP:53880---ęćółąćśżńźŁĆŚŹŻ
              : 0 2 10 Ko---ęćółąćśżńźŁĆŚŹŻ
              : 2 2 7 chać---ęćółąćśżńźŁĆŚŹŻ
              : 4 4 7 ci---ęćółąćśżńźŁĆŚŹŻ
              : 8 2 5 ę,---ęćółąćśżńźŁĆŚŹŻ
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              #TITLE:Nie Mogę Cię Zapomnieć---ęćółąćśżńźŁĆŚŹŻ
              #ARTIST:Agnieszka Chylińska---ęćółąćśżńźŁĆŚŹŻ
              #LANGUAGE:Polish---ęćółąćśżńźŁĆŚŹŻ
              #GENRE:Pop---ęćółąćśżńźŁĆŚŹŻ
              #YEAR:2009---ęćółąćśżńźŁĆŚŹŻ
              #CREATOR:davidus01---ęćółąćśżńźŁĆŚŹŻ
              #MP3:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć.mp3---ęćółąćśżńźŁĆŚŹŻ
              #COVER:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć [CO].jpg---ęćółąćśżńźŁĆŚŹŻ
              #BACKGROUND:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć [BG].jpg---ęćółąćśżńźŁĆŚŹŻ
              #VIDEO:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć.mp4---ęćółąćśżńźŁĆŚŹŻ
              #VIDEOGAP:1---ęćółąćśżńźŁĆŚŹŻ
              #BPM:126,37---ęćółąćśżńźŁĆŚŹŻ
              #GAP:53880---ęćółąćśżńźŁĆŚŹŻ
              : 0 2 10 Ko---ęćółąćśżńźŁĆŚŹŻ
              : 2 2 7 chać---ęćółąćśżńźŁĆŚŹŻ
              : 4 4 7 ci---ęćółąćśżńźŁĆŚŹŻ
              : 8 2 5 ę,---ęćółąćśżńźŁĆŚŹŻ
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              #MP3:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć.mp3---ęćółąćśżńźŁĆŚŹŻ
              

              It should give the expected text :

              #TITLE:Nie Mogę Cię Zapomnieć---ęćółąćśżńźŁĆŚŹŻ
              #ARTIST:Agnieszka Chylińska---ęćółąćśżńźŁĆŚŹŻ
              #LANGUAGE:Polish---ęćółąćśżńźŁĆŚŹŻ
              #GENRE:Pop---ęćółąćśżńźŁĆŚŹŻ
              #YEAR:2009---ęćółąćśżńźŁĆŚŹŻ
              #CREATOR:davidus01---ęćółąćśżńźŁĆŚŹŻ
              #MP3:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo.mp3---colacoznzLCSZZ
              #COVER:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo [CO].jpg---colacoznzLCSZZ
              #BACKGROUND:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo [BG].jpg---colacoznzLCSZZ
              #VIDEO:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo.mp4---colacoznzLCSZZ
              #VIDEOGAP:1---ęćółąćśżńźŁĆŚŹŻ
              #BPM:126,37---ęćółąćśżńźŁĆŚŹŻ
              #GAP:53880---ęćółąćśżńźŁĆŚŹŻ
              : 0 2 10 Ko---ęćółąćśżńźŁĆŚŹŻ
              : 2 2 7 chać---ęćółąćśżńźŁĆŚŹŻ
              : 4 4 7 ci---ęćółąćśżńźŁĆŚŹŻ
              : 8 2 5 ę,---ęćółąćśżńźŁĆŚŹŻ
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              #TITLE:Nie Mogę Cię Zapomnieć---ęćółąćśżńźŁĆŚŹŻ
              #ARTIST:Agnieszka Chylińska---ęćółąćśżńźŁĆŚŹŻ
              #LANGUAGE:Polish---ęćółąćśżńźŁĆŚŹŻ
              #GENRE:Pop---ęćółąćśżńźŁĆŚŹŻ
              #YEAR:2009---ęćółąćśżńźŁĆŚŹŻ
              #CREATOR:davidus01---ęćółąćśżńźŁĆŚŹŻ
              #MP3:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo.mp3---colacoznzLCSZZ
              #COVER:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo [CO].jpg---colacoznzLCSZZ
              #BACKGROUND:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo [BG].jpg---colacoznzLCSZZ
              #VIDEO:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo.mp4---colacoznzLCSZZ
              #VIDEOGAP:1---ęćółąćśżńźŁĆŚŹŻ
              #BPM:126,37---ęćółąćśżńźŁĆŚŹŻ
              #GAP:53880---ęćółąćśżńźŁĆŚŹŻ
              : 0 2 10 Ko---ęćółąćśżńźŁĆŚŹŻ
              : 2 2 7 chać---ęćółąćśżńźŁĆŚŹŻ
              : 4 4 7 ci---ęćółąćśżńźŁĆŚŹŻ
              : 8 2 5 ę,---ęćółąćśżńźŁĆŚŹŻ
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              #MP3:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo.mp3---colacoznzLCSZZ
              

              Notes :

              • Tick the Wrap around option and choose the Regular expression search mode

              • IMPORTANT : if you just want to visualize the different matches, with the Find Next button, you must move the caret to the very beginning of current file, with the Ctrl + Home shortcut, before searching !

              Best Regards,

              guy038

              PeterJonesP 1 Reply Last reply Reply Quote 1
              • PeterJonesP
                PeterJones @guy038
                last edited by

                @guy038 said in Replace multiple characters only in lines starting with specific words:

                SEARCH (?-si:#(MP3|COVER|BACKGROUND|VIDEO):|(?!\A)\G).*?\K(?:(ę)|(ć)|(ó)|(ł)|(ą)|(ć)|(ś)|(ż)|(ń)|(ź)|(Ł)|(Ć)|(Ś)|(Ź)|(Ż))

                You inherited the bug I partially fixed, but missed one that I didn’t see until after my 3minute window… but without the ?: in the MP3|COVER|BACKGROUND|VIDEO group, that becomes group 1, and the substitutions are off by one group. Hence,

                #MP3:Agnieszka Chylińska - Nie Mogę Cię Zapomnieć.mp3---ęćółąćśżńźŁĆŚŹŻ
                

                becomes

                #MP3:Agnieszka Chyliezska - Nie Mogc Cic Zapomnieo.mp3---colacoznzLCSZZ
                

                where it should have become

                #MP3:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp3---ecolacsznzlCSZZ
                

                Also, because you weren’t wrapping it in the old generic FR wrapper section, you lost the ?-i around the FR, so it wasn’t guaranteed to be doing a case-sensitive search (unless you happened to have the case-sensitive checkmark clicked) for the accented characters, and gave me cszz instead of CSZZ as the last four characters.

                It should be

                SEARCH (?-si:#(?:MP3|COVER|BACKGROUND|VIDEO):|(?!\A)\G).*?\K(?-i:(ę)|(ć)|(ó)|(ł)|(ą)|(ć)|(ś)|(ż)|(ń)|(ź)|(Ł)|(Ć)|(Ś)|(Ź)|(Ż))

                and result in

                #TITLE:Nie Mogę Cię Zapomnieć---ęćółąćśżńźŁĆŚŹŻ
                #ARTIST:Agnieszka Chylińska---ęćółąćśżńźŁĆŚŹŻ
                #LANGUAGE:Polish---ęćółąćśżńźŁĆŚŹŻ
                #GENRE:Pop---ęćółąćśżńźŁĆŚŹŻ
                #YEAR:2009---ęćółąćśżńźŁĆŚŹŻ
                #CREATOR:davidus01---ęćółąćśżńźŁĆŚŹŻ
                #MP3:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp3---ecolacsznzLCSZZ
                #COVER:Agnieszka Chylinska - Nie Moge Cie Zapomniec [CO].jpg---ecolacsznzLCSZZ
                #BACKGROUND:Agnieszka Chylinska - Nie Moge Cie Zapomniec [BG].jpg---ecolacsznzLCSZZ
                #VIDEO:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp4---ecolacsznzLCSZZ
                #VIDEOGAP:1---ęćółąćśżńźŁĆŚŹŻ
                #BPM:126,37---ęćółąćśżńźŁĆŚŹŻ
                #GAP:53880---ęćółąćśżńźŁĆŚŹŻ
                : 0 2 10 Ko---ęćółąćśżńźŁĆŚŹŻ
                : 2 2 7 chać---ęćółąćśżńźŁĆŚŹŻ
                : 4 4 7 ci---ęćółąćśżńźŁĆŚŹŻ
                : 8 2 5 ę,---ęćółąćśżńźŁĆŚŹŻ
                -----------------------------
                #TITLE:Nie Mogę Cię Zapomnieć---ęćółąćśżńźŁĆŚŹŻ
                #ARTIST:Agnieszka Chylińska---ęćółąćśżńźŁĆŚŹŻ
                #LANGUAGE:Polish---ęćółąćśżńźŁĆŚŹŻ
                #GENRE:Pop---ęćółąćśżńźŁĆŚŹŻ
                #YEAR:2009---ęćółąćśżńźŁĆŚŹŻ
                #CREATOR:davidus01---ęćółąćśżńźŁĆŚŹŻ
                #MP3:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp3---ecolacsznzLCSZZ
                #COVER:Agnieszka Chylinska - Nie Moge Cie Zapomniec [CO].jpg---ecolacsznzLCSZZ
                #BACKGROUND:Agnieszka Chylinska - Nie Moge Cie Zapomniec [BG].jpg---ecolacsznzLCSZZ
                #VIDEO:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp4---ecolacsznzLCSZZ
                #VIDEOGAP:1---ęćółąćśżńźŁĆŚŹŻ
                #BPM:126,37---ęćółąćśżńźŁĆŚŹŻ
                #GAP:53880---ęćółąćśżńźŁĆŚŹŻ
                : 0 2 10 Ko---ęćółąćśżńźŁĆŚŹŻ
                : 2 2 7 chać---ęćółąćśżńźŁĆŚŹŻ
                : 4 4 7 ci---ęćółąćśżńźŁĆŚŹŻ
                : 8 2 5 ę,---ęćółąćśżńźŁĆŚŹŻ
                -----------------------------
                #MP3:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp3---ecolacsznzLCSZZ
                

                But yes, your optimization cleans it up some in terms of making the final regex less complex looking.

                @kuba,

                So, as you can see, there are multiple ways to accomplish these goals using regex. I suggested the generic regex, because I think that’s a slightly easier pattern for people new to regex to learn… so the process I would suggest for someone who doesn’t necessarily want to dig into the guts of the regex right away is for you to use this process: when you want to search and replace but only between certain start and end markers, use with the generic formula. Then, if it doesn’t end up being sufficient on certain edge cases, or if you want to learn more about how it’s working, you can start digging into how the individual pieces are working, and looking at the references I provided to help guide you.

                In the end, it will behoove you to practice more with regex, and read those references that we gave you, and experiment with examples that you find here in the forum, so that you can get better at solving your regex questions on your own… which will be better for your data processing in the long run than relying on us (or other such forums) to develop your regex for you.

                1 Reply Last reply Reply Quote 1
                • guy038G
                  guy038
                  last edited by guy038

                  Hi, @kuba, @peterjones, and All,

                  Peter, as my regex began with (?-si:#, I thought that it was not necessary to add the -i modifier for the FR section ! I was totally wrong :-( Indeed, we have to remember that the action of modifiers, located within a non-capturing group, are local to this non-capturing group !

                  For instance, let’s suppose that you use the regex (?-s:ABC).*XYZ against this text :

                  ABC   DEF  XYZ  GHI  XYZ   PQR
                  
                  blah blah
                  
                  ABC   XYZ   GHI  XYZ  DEF
                  
                  • If you did not tick the . matches new line option, this regex matches the string ABC DEF XYZ GHI XYZ of the first line

                  • If you ticked the . matches new line option, this regex matches from the first ABC string till the last XYZ of the fifth line

                  • BUT, if you use the regex (?-s)(?:ABC).*XYZ, then, whatever the status of the . matches new line option, it will always match the string ABC DEF XYZ GHI XYZ of the first line ! In that case, the (?-s) is considered as a global modifier, which may be only modified with a further (?s) syntax, either, inside or outside a non-capturing group !


                  Secondly, as Peter noticed it, I used in my previous regex, the part (MP3|COVER|BACKGROUND|VIDEO) which stores one of these headers as group 1

                  Unfortunately, all the other group numbers are increased by one, making the transliteration inaccurate ! I should had considered the non-capturing group (?:MP3|COVER|BACKGROUND|VIDEO)


                  Finally, as both the (?-i) and the (?-s) modifiers must apply in all parts of the overall regex, may be, the right syntax could be :

                  SEARCH (?-is)(?:#(?:MP3|COVER|BACKGROUND|VIDEO):|(?!\A)\G).*?\K(?:(ę)|(ć)|(ó)|(ł)|(ą)|(ć)|(ś)|(ż)|(ń)|(ź)|(Ł)|(Ć)|(Ś)|(Ź)|(Ż))

                  REPLACE (?1e)(?2c)(?3o)(?4l)(?5a)(?6c)(?7s)(?8z)(?9n)(?10z)(?11L)(?12C)(?13S)(?14Z)(?15Z)

                  With this formulation, we’re sure that the part (ę) is the group 1 !


                  And, after replacement, the correct transliteration of accentuated characters is effective only within the bloc below :

                  #MP3:
                  #COVER:
                  #BACKGROUND:
                  #VIDEO:
                  

                  and gives, at last, the expected result :

                  #TITLE:Nie Mogę Cię Zapomnieć---ęćółąćśżńźŁĆŚŹŻ
                  #ARTIST:Agnieszka Chylińska---ęćółąćśżńźŁĆŚŹŻ
                  #LANGUAGE:Polish---ęćółąćśżńźŁĆŚŹŻ
                  #GENRE:Pop---ęćółąćśżńźŁĆŚŹŻ
                  #YEAR:2009---ęćółąćśżńźŁĆŚŹŻ
                  #CREATOR:davidus01---ęćółąćśżńźŁĆŚŹŻ
                  #MP3:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp3---ecolacsznzLCSZZ
                  #COVER:Agnieszka Chylinska - Nie Moge Cie Zapomniec [CO].jpg---ecolacsznzLCSZZ
                  #BACKGROUND:Agnieszka Chylinska - Nie Moge Cie Zapomniec [BG].jpg---ecolacsznzLCSZZ
                  #VIDEO:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp4---ecolacsznzLCSZZ
                  #VIDEOGAP:1---ęćółąćśżńźŁĆŚŹŻ
                  #BPM:126,37---ęćółąćśżńźŁĆŚŹŻ
                  #GAP:53880---ęćółąćśżńźŁĆŚŹŻ
                  : 0 2 10 Ko---ęćółąćśżńźŁĆŚŹŻ
                  : 2 2 7 chać---ęćółąćśżńźŁĆŚŹŻ
                  : 4 4 7 ci---ęćółąćśżńźŁĆŚŹŻ
                  : 8 2 5 ę,---ęćółąćśżńźŁĆŚŹŻ
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  #TITLE:Nie Mogę Cię Zapomnieć---ęćółąćśżńźŁĆŚŹŻ
                  #ARTIST:Agnieszka Chylińska---ęćółąćśżńźŁĆŚŹŻ
                  #LANGUAGE:Polish---ęćółąćśżńźŁĆŚŹŻ
                  #GENRE:Pop---ęćółąćśżńźŁĆŚŹŻ
                  #YEAR:2009---ęćółąćśżńźŁĆŚŹŻ
                  #CREATOR:davidus01---ęćółąćśżńźŁĆŚŹŻ
                  #MP3:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp3---ecolacsznzLCSZZ
                  #COVER:Agnieszka Chylinska - Nie Moge Cie Zapomniec [CO].jpg---ecolacsznzLCSZZ
                  #BACKGROUND:Agnieszka Chylinska - Nie Moge Cie Zapomniec [BG].jpg---ecolacsznzLCSZZ
                  #VIDEO:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp4---ecolacsznzLCSZZ
                  #VIDEOGAP:1---ęćółąćśżńźŁĆŚŹŻ
                  #BPM:126,37---ęćółąćśżńźŁĆŚŹŻ
                  #GAP:53880---ęćółąćśżńźŁĆŚŹŻ
                  : 0 2 10 Ko---ęćółąćśżńźŁĆŚŹŻ
                  : 2 2 7 chać---ęćółąćśżńźŁĆŚŹŻ
                  : 4 4 7 ci---ęćółąćśżńźŁĆŚŹŻ
                  : 8 2 5 ę,---ęćółąćśżńźŁĆŚŹŻ
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  #MP3:Agnieszka Chylinska - Nie Moge Cie Zapomniec.mp3---ecolacsznzLCSZZ
                  

                  Best Regards,

                  guy038

                  1 Reply Last reply Reply Quote 1
                  • KubaK
                    Kuba
                    last edited by

                    Gentlemen! Thank you very much for your help. Everything works like a charm. Your experience is invaluable!

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors