• Login
Community
  • Login

How to suceed these actions in notepad++ (images included)

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
19 Posts 4 Posters 873 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.
  • D
    DJSpirosG
    last edited by Jul 8, 2020, 9:31 PM

    I would like to reform this text (1st Image) to how the second one (image) looks like. So i wonder if there are some quick regex actions to bookmark these lines (I know how to remove them afterwards) and then reform the text file as the 2nd picture shows.

    Thank you

    Annotation 2020-07-09 001434.jpg

    Annotation 2020-07-09 001637.jpg

    1 Reply Last reply Reply Quote 0
    • T
      Terry R
      last edited by Terry R Jul 8, 2020, 10:20 PM Jul 8, 2020, 10:19 PM

      @DJ-SpirosG said in How to suceed these actions in notepad++ (images included):

      I would like to reform this text

      First off, welcome to the forum.

      One possible solution might be using the Replace function
      Find What:(?-s)^(.+)\R\R(.+\R)(.+\R)(.+\R*)
      Replace With:\1 - \2
      Search mode must be “regular expression” and the cursor MUST be in the very first position in the file.

      There is an unknown though, you show what appears to be a portion of a file, whether it’s in the middle, start or end matters considerably.

      If we consider it’s the start of a file, then the last line appears to be 2 lines short of the end of file. If it’s the end of a file then the start of your example is the 3rd line into the file. What I’m trying to explain here is that using your example we appear to have a set of 5 lines. They will be either:
      scenario 1:
      song name
      blank line
      singer/author
      number
      type

      or
      scenario 2:
      number
      type
      song name
      blank line
      singer/author

      My solution goes with scenario 1, therefore it is assuming the last 2 lines in the file will be the “number” and “type” lines.

      You need to provide more information, ideally confirming which scenario I have supplied is the correct one. It’s preferable to supply some dummy (or real data) in text form rather than images so it’s easier for us to copy it, rather than having to recreate it and hope it replicates your data. To do so, use the FAQ and read the post relating to “Request for Help without sufficient information to help” as it provides insight into how to provide the data so it is not affected by the markdown language the posting engine uses.

      Terry

      D 1 Reply Last reply Jul 8, 2020, 11:12 PM Reply Quote 3
      • G
        guy038
        last edited by guy038 Jul 8, 2020, 11:19 PM Jul 8, 2020, 11:11 PM

        Hello, @dj-spirosg, @Terry-r and All,

        I’ve found out a regex which does not care about incomplete records ;-))

        For instance, let’s assume this simple initial text

        Song_1
        
        Singer_1
        Id_1
        Type_1
        Song_2
        
        Singer_2
        Id_2
        Type_2
        Song_3
        
        Singer_3
        Id_3
        Type_3
        Song_4
        
        Singer_4
        Id_4
        Type_4
        Song_5
        
        Singer_5
        Id_5
        Type_5
        Song_6
        
        Singer_6
        Id_6
        Type_6
        

        Now, if I add, right before the Song_1 line, the line :

        Type_0
        

        or, even, the two lines :

        Id_0
        Type_0
        

        The following regex S/R still works :

        SEARCH (?-s)^(.+)\R(\R(.+))?

        REPLACE ?2\1\x20-\x20\3

        and produces this expected result :

        Song_1 - Singer_1
        Song_2 - Singer_2
        Song_3 - Singer_3
        Song_4 - Singer_4
        Song_5 - Singer_5
        Song_6 - Singer_6
        

        Of course the search regex is based on the fact there’s always a pure blank line between the song name and the singer name !

        Best Regards,

        guy038

        D 1 Reply Last reply Jul 8, 2020, 11:20 PM Reply Quote 2
        • D
          DJSpirosG @Terry R
          last edited by DJSpirosG Jul 8, 2020, 11:14 PM Jul 8, 2020, 11:12 PM

          @Terry-R said in How to suceed these actions in notepad++ (images included):

          \1 - \2

          @Terry-R you are a legeng thank you!
          Scenario 1 works perfect!

          I will be more carefull when i’m posting stuff here, sorry for that!

          I have one more question for if the text looks like that

          SAINt JHN
          Roses (Imanbek Remix)
          Benee feat. Gus Dapperton
          Supalonely (Petedown Club Mix)
          Harry Styles
          Watermelon Sugar (Kue Remix)

          What regex should i use to reform it to

          SAINt JHN - Roses (Imanbek Remix)
          Benee feat. Gus Dapperton - Supalonely (Petedown Club Mix)
          Harry Styles - Watermelon Sugar (Kue Remix)

          Annotation 2020-07-09 021327.jpg

          1 Reply Last reply Reply Quote 0
          • D
            DJSpirosG @guy038
            last edited by Jul 8, 2020, 11:20 PM

            @guy038 said in How to suceed these actions in notepad++ (images included):

            ?2\1\x20-\x20\3

            @guy038 this one is also working flawlessly!!!
            Thanks for the help guys, appreciated!

            1 Reply Last reply Reply Quote 0
            • T
              Terry R
              last edited by Jul 8, 2020, 11:21 PM

              @DJ-SpirosG said in How to suceed these actions in notepad++ (images included):

              if the text looks like that

              Before I supply anything I see you haven’t read that FAQ I mentioned. I welcome the “text” based example, however from the image you also supplied I can see the 2nd line is indented. That could be a number of spaces or a tab. The markdown language has interpreted and changed your text based example, thus removing the tab or spaces in front of every 2nd line.

              I point you back to the FAQ post and specifically the portion mentioning how to insert text using the 3 backtick and z character, then the example and followed by the 3 backticks again.

              How about you try and provide the example again using that formatting.

              Terry

              D 1 Reply Last reply Jul 8, 2020, 11:27 PM Reply Quote 2
              • D
                DJSpirosG @Terry R
                last edited by DJSpirosG Jul 8, 2020, 11:27 PM Jul 8, 2020, 11:27 PM

                @Terry-R You are right i didn’t read it (yet) and yes you are also right that the text i posted changed, there are two spaces in front of every second line. Sorry for that it was because i was trying to confirm that your script was correct.

                Am heading over to the FAQ right now.

                Thanks for the help, appreciated!

                1 Reply Last reply Reply Quote 0
                • G
                  guy038
                  last edited by guy038 Jul 9, 2020, 12:04 AM Jul 8, 2020, 11:30 PM

                  Hello, @djspirosg, @terry-r and All,

                  Ah OK, @djspirosg ! I succeeded to merge your two cases :

                  • The song name is followed with a pure blank line, then, with the singer name

                  • The song name is immediately followed with some leading blank characters and the singer name


                  So, assuming this initial data :

                  Song_1
                  
                  Singer_1
                  Id_1
                  Type_1
                  Song_2
                    Singer_2
                  Id_2
                  Type_2
                  Song_3
                  
                  Singer_3
                  Id_3
                  Type_3
                  Song_4
                    Singer_4
                  Id_4
                  Type_4
                  Song_5
                  
                  Singer_5
                  Id_5
                  Type_5
                  Song_6
                    Singer_6
                  Id_6
                  Type_6
                  

                  The regex S/R, below :

                  SEARCH (?-s)^(.+)\R((\R|\h+)(.+))?

                  REPLACE ?2\1\x20-\x20\4

                  give us the expected data, too :

                  Song_1 - Singer_1
                  Song_2 - Singer_2
                  Song_3 - Singer_3
                  Song_4 - Singer_4
                  Song_5 - Singer_5
                  Song_6 - Singer_6
                  

                  Cheers,

                  guy038

                  D 1 Reply Last reply Jul 8, 2020, 11:34 PM Reply Quote 2
                  • D
                    DJSpirosG @guy038
                    last edited by DJSpirosG Jul 8, 2020, 11:34 PM Jul 8, 2020, 11:34 PM

                    @guy038 I have no words mate!!! This works!!!

                    A huge thank you once again!!!

                    @Terry-R

                    This is the correct way to post the exact text ( I hope :-) )

                    SAINt JHN
                      Roses (Imanbek Remix)
                    Benee feat. Gus Dapperton
                      Supalonely (Petedown Club Mix)
                    Harry Styles
                      Watermelon Sugar (Kue Remix)
                    Doja Cat
                      Say So (Jax Jones Midnight Snack Remix)
                    
                    1 Reply Last reply Reply Quote 2
                    • G
                      guy038
                      last edited by guy038 Jul 9, 2020, 12:06 AM Jul 8, 2020, 11:45 PM

                      Hello, @djspirosg and All,

                      Note that, in my search regex, the \h+ syntax stands for any non-null number of consecutive horizontal blank characters, so a single tab char, instead of two space chars, would be OK, too !

                      Strictly speaking, the \h syntax is identical to the class range character [\t\x20\xA0] and \H is identical to the negative class [^\t\x20\xa0]

                      BR

                      guy038

                      1 Reply Last reply Reply Quote 2
                      • D
                        DJSpirosG
                        last edited by Jul 9, 2020, 12:26 PM

                        Have a nice day!

                        I really appreciate the time you have spent to help me and solve my “problems”.

                        Now that i found you i can’t resist on asking for some more help!!! :-)
                        I tried the scripts from above but they didn’t work. I also tried to edit them a bit without luck (Noob here sorry)

                        So the original text is (the first line is blank):

                        
                        1
                        Tap In (Club Killers Hyphy Wordplay Segue Pack)
                        Saweetie, E40, Keak Da Sneak, Mac Dre
                        
                            Tap In vs. Tell Me When To Go - Clean | Tap In vs. Tell Me When To Go - Dirty | Tap In vs. Feelin Myself - Clean | Tap In vs. Feelin Myself - Dirty | Tap In vs. Super Hyphy - Clean | Tap In vs. Super Hyphy - Dirty
                            06/24/2020
                            BPM: 100
                            KEY: 1A
                        
                        2
                        Shimmy Shimmy Shimmy Ya (Club Killers Wordplay Segue)
                        Ol' Dirty Bastard, Lil Wayne, Doja Cat
                        
                            Clean - Piano In | Dirty - Piano In | Clean - Scratch In | Dirty - Scratch In
                            06/10/2020
                            BPM: 98
                            KEY: 12A
                        
                        3
                        Just A Lil Bit (Club Killers Blend)
                        Scott Storch ft Ozuna & Tyga vs 50 Cent
                        
                            Intro - Clean | Intro - Dirty | Blend To OG - Clean | Blend To OG - Dirty
                            05/29/2020
                            BPM: 100
                            KEY: 1A
                        
                        4
                        

                        Now i want to format it to:

                        Tap In (Club Killers Hyphy Wordplay Segue Pack) - Saweetie, E40, Keak Da Sneak, Mac Dre
                        Shimmy Shimmy Shimmy Ya (Club Killers Wordplay Segue) - Ol' Dirty Bastard, Lil Wayne, Doja Cat
                        Just A Lil Bit (Club Killers Blend) - Scott Storch ft Ozuna & Tyga vs 50 Cent
                        Back It Up (DJ Nasa VIP Rework) - Trap Beckham ft Flo Milli
                        
                        Alan KilbornA 1 Reply Last reply Jul 9, 2020, 12:30 PM Reply Quote 0
                        • Alan KilbornA
                          Alan Kilborn @DJSpirosG
                          last edited by Jul 9, 2020, 12:30 PM

                          @DJSpirosG said in How to suceed these actions in notepad++ (images included):

                          Now that i found you i can’t resist on asking for some more help!!! :-)

                          Yes, a common theme here.
                          People just want to use this as a (FREE) data conversion service.
                          They don’t want to actually learn anything.
                          Don’t be one of those.
                          Because you will get cut off.

                          I tried the scripts from above but they didn’t work. I also tried to edit them a bit without luck

                          To get further assistance, tell us what you tried and what was the result you obtained.
                          Then you can probably get steered in the correct direction.
                          But to just say it doesn’t work isn’t going to get you anything.

                          D 1 Reply Last reply Jul 9, 2020, 12:45 PM Reply Quote 2
                          • D
                            DJSpirosG @Alan Kilborn
                            last edited by Jul 9, 2020, 12:45 PM

                            @Alan-Kilborn

                            Hi @Alan-Kilborn sorry but i’m not used to how regex works, especially when it’s complicated.
                            I’m trying to understand some of the scripts but i don’t really have the basic knowledge to succeed that most of the times.
                            I Tried to change the values (first 2 numbers and the last one) on the replace with ?2\1\x20-\x20\4 cell to see if i will succeed what i want to but i didn’t find a working script. as i told you am not familiar with regex language (i wish to).

                            1 Reply Last reply Reply Quote 0
                            • G
                              guy038
                              last edited by guy038 Jul 9, 2020, 4:17 PM Jul 9, 2020, 4:07 PM

                              Hello, @djspirosg, @Terry-r, @alan-kilborn and All,

                              So, assuming this piece of data :

                              1
                              Tap In (Club Killers Hyphy Wordplay Segue Pack)
                              Saweetie, E40, Keak Da Sneak, Mac Dre
                              
                                  Tap In vs. Tell Me When To Go - Clean | Tap In vs. Tell Me When To Go - Dirty | Tap In vs. Feelin Myself - Clean | Tap In vs. Feelin Myself - Dirty | Tap In vs. Super Hyphy - Clean | Tap In vs. Super Hyphy - Dirty
                                  06/24/2020
                                  BPM: 100
                                  KEY: 1A
                              
                              2
                              Shimmy Shimmy Shimmy Ya (Club Killers Wordplay Segue)
                              Ol' Dirty Bastard, Lil Wayne, Doja Cat
                              
                                  Clean - Piano In | Dirty - Piano In | Clean - Scratch In | Dirty - Scratch In
                                  06/10/2020
                                  BPM: 98
                                  KEY: 12A
                              
                              3
                              Just A Lil Bit (Club Killers Blend)
                              Scott Storch ft Ozuna & Tyga vs 50 Cent
                              
                                  Intro - Clean | Intro - Dirty | Blend To OG - Clean | Blend To OG - Dirty
                                  05/29/2020
                                  BPM: 100
                                  KEY: 1A
                              

                              The following regex S/R :

                              SEARCH (?-s)^(?![\h\d])(.+)\R(?![\h\d])(.+)|^.*\R

                              REPLACE ?1\1\x20-\x20\2

                              would return the expected text, below :

                              Tap In (Club Killers Hyphy Wordplay Segue Pack) - Saweetie, E40, Keak Da Sneak, Mac Dre
                              Shimmy Shimmy Shimmy Ya (Club Killers Wordplay Segue) - Ol' Dirty Bastard, Lil Wayne, Doja Cat
                              Just A Lil Bit (Club Killers Blend) - Scott Storch ft Ozuna & Tyga vs 50 Cent
                              

                              Notes :

                              • As usual, the (?-s) in-line modifier ensures that the regex dot symbol represents a single standard character and not a line-break character

                              • Then, the (?![\h\d]) is a negative look-ahead structure which tells the regex engine that a blanck or a digit character is not supposed to be at beginning of lines searched

                              • Now, the part .+\R matches all the contents of current line with its line-break char(s)

                              • Again, the part (?![\h\d])(.+) looks for all contents of a line, without the line-break chars,not beginning with, either, a digit or a blank character

                              • If current scanned line does not respect the previous condition, all its contents with its line-break chars, including true empty lines, are matched with the ^.*\R pattern, located after the alternation symbol |

                              • In replacement, the syntax (?#.....), or ?#....., is a conditional replacement which means :

                                • If group 1 exists (.+), then groups 1 and 2 must be rewritten, separated with a space, a dash and a space again , so the regex \1\x20-\x20\2

                                • If the second alternative matches, group 1 does not exist, so all these other lines are simply deleted


                              For a quick overview of regular expressions, begin here :

                              https://www.regular-expressions.info/quickstart.html

                              You’ll find additional information here

                              Best Regards,

                              guy038

                              D 2 Replies Last reply Jul 9, 2020, 4:19 PM Reply Quote 2
                              • D
                                DJSpirosG @guy038
                                last edited by Jul 9, 2020, 4:19 PM

                                @guy038 Hi, I have no words mate, thanks for the time you are spending to help me and also teach me/explain me the logic of regex.

                                The explanation is really useful to help me understand how it actually works!!!

                                I’ll start reading it ASAP.

                                Once again, thank you!

                                1 Reply Last reply Reply Quote 0
                                • D
                                  DJSpirosG @guy038
                                  last edited by Jul 9, 2020, 4:26 PM

                                  @guy038 said in How to suceed these actions in notepad++ (images included):

                                  Then, the (?![\h\d]) is a negative look-ahead structure which tells the regex engine that a blanck or a digit character is not supposed to be at beginning of lines searched

                                  @guy038 What if the song or the artist name starts with a digit though?

                                  ex.

                                  8
                                  Trollz (DJ Nasa Vip Edit)
                                  6ix9ine ft Nicki Minaj vs Lil Jon
                                  
                                      Intro - Clean | Intro - Dirty | Slam In - Clean | Slam In - Dirty | Acap In - Clean | Acap In - Dirty
                                      06/18/2020
                                      BPM: 95
                                      KEY: 12A
                                  
                                  9
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • D
                                    DJSpirosG
                                    last edited by Jul 9, 2020, 5:18 PM

                                    @guy038 I think i found how to Solve the problem with a song or an artist starting with a digit!

                                    SEARCH (?-s)^(?![\h\d])(.+)\R(?![\h])(.+)|^.*\R

                                    REPLACE ?1\1\x20-\x20\2

                                    1 Reply Last reply Reply Quote 3
                                    • G
                                      guy038
                                      last edited by Jul 9, 2020, 5:30 PM

                                      Hi, @djspirosg and All,

                                      Ah…OK. In that case, we’re going to change the condition inside the look-ahead !

                                      The lines which must be joined with a dash ``-` symbol must NOT begin with, either :

                                      • An horizontal blank character ( then, this covers the case several blank chars, too ! )

                                      • One or several digit char(s), immediately followed with line-break char(s)

                                      So, the negative look-ahead becomes (?!\h|\d+\R)

                                      This new syntax allows, both, the song and the artist name to begins with one or several digits

                                      So, assuming this text :

                                      1
                                      1Tap In (Club Killers Hyphy Wordplay Segue Pack)
                                      12345Saweetie, E40, Keak Da Sneak, Mac Dre
                                      
                                          Tap In vs. Tell Me When To Go - Clean | Tap In vs. Tell Me When To Go - Dirty | Tap In vs. Feelin Myself - Clean | Tap In vs. Feelin Myself - Dirty | Tap In vs. Super Hyphy - Clean | Tap In vs. Super Hyphy - Dirty
                                          06/24/2020
                                          BPM: 100
                                          KEY: 1A
                                      
                                      2
                                      22Shimmy Shimmy Shimmy Ya (Club Killers Wordplay Segue)
                                      000Ol' Dirty Bastard, Lil Wayne, Doja Cat
                                      
                                          Clean - Piano In | Dirty - Piano In | Clean - Scratch In | Dirty - Scratch In
                                          06/10/2020
                                          BPM: 98
                                          KEY: 12A
                                      
                                      3
                                      33333Just A Lil Bit (Club Killers Blend)
                                      3Scott Storch ft Ozuna & Tyga vs 50 Cent
                                      
                                          Intro - Clean | Intro - Dirty | Blend To OG - Clean | Blend To OG - Dirty
                                          05/29/2020
                                          BPM: 100
                                          KEY: 1A
                                      

                                      With that regex S/R :

                                      SEARCH (?-s)^(?!\h|\d+\R)(.+)\R(?!\h|\d+\R)(.+)|^.*\R

                                      REPLACE ?1\1\x20-\x20\2

                                      you’ll get this result, where all the artist’s names and song’s name begin with a number !

                                      1Tap In (Club Killers Hyphy Wordplay Segue Pack) - 12345Saweetie, E40, Keak Da Sneak, Mac Dre
                                      22Shimmy Shimmy Shimmy Ya (Club Killers Wordplay Segue) - 000Ol' Dirty Bastard, Lil Wayne, Doja Cat
                                      33333Just A Lil Bit (Club Killers Blend) - 3Scott Storch ft Ozuna & Tyga vs 50 Cent
                                      

                                      Thanks for searching on your own ! Your regex is OK if the second line begins with a digit but would not work if the first line would begin with a digit !

                                      BR

                                      guy038

                                      D 1 Reply Last reply Jul 9, 2020, 6:46 PM Reply Quote 2
                                      • D
                                        DJSpirosG @guy038
                                        last edited by DJSpirosG Jul 9, 2020, 6:48 PM Jul 9, 2020, 6:46 PM

                                        @guy038 said in How to suceed these actions in notepad++ (images included):

                                        Thanks for searching on your own ! Your regex is OK if the second line begins with a digit but would not work if the first line would begin with a digit

                                        I’am trying to learn! Not successfully i guess :-P

                                        You are right i haven’t thought about the first line, i was focusing on artist because of my example. I don’t say that i could solve it though :-)

                                        By the way your script works flawlessly

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