Community
    • Login

    How to find the first space in all lines?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 2 Posters 676 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.
    • Emalino EmaleroE
      Emalino Emalero
      last edited by Emalino Emalero

      I have a txt file with more than 3 thousand lines, I want to detect the first space in all lines and add a ]
      Original file format

      [fgggj oooo m6cmp5
      [5jgidd udd64j kkrt7 8d66sdjnd
      [hfhfh maoerchgu 996d63542
      [mmnkiiuy45 oiudzzc3

      Would be like this

      [fgggj]oooo m6cmp5
      [5jgidd]udd64j kkrt7 8d66sdjnd
      [hfhfh]maoerchgu 996d63542
      [mmnkiiuy45]oiudzzc3

      Next, use a regex that eliminates everything outside []

      Final result

      [fgggj]
      [5jgidd]
      [hfhfh]
      [mmnkiiuy45]

      It’s possible? Thank you for any help.

      CoisesC 1 Reply Last reply Reply Quote 0
      • CoisesC
        Coises @Emalino Emalero
        last edited by

        @Emalino-Emalero

        Find what : ^(\S++)[^\r\n]++
        Replace with : $1]

        Emalino EmaleroE 1 Reply Last reply Reply Quote 1
        • Emalino EmaleroE
          Emalino Emalero @Coises
          last edited by

          Thank you very much, Coises. It worked perfectly, saved my weekend! I applied the regex, using Linux Debian Sid, Notepad++ running via wine. Sorted out!

          1 Reply Last reply Reply Quote 0
          • Emalino EmaleroE
            Emalino Emalero
            last edited by Emalino Emalero

            Sorry to bother you, but I have a question that I may need in the future. If I wanted to do the opposite, in the end result removing everything inside [] including [] itself, would it be possible? The end result would be this:

            oooo m6cmp5
            udd64j kkrt7 8d66sdjnd
            maoerchgu 996d63542
            oiudzzc3

            CoisesC 1 Reply Last reply Reply Quote 0
            • CoisesC
              Coises @Emalino Emalero
              last edited by

              @Emalino-Emalero said in How to find the first space in all lines?:

              Sorry to bother you, but I have a question that I may need in the future. If I wanted to do the opposite, in the end result removing everything inside [] including [] itself, would it be possible? The end result would be this:

              Find what : ^(\S++)\h
              Replace with : (empty)

              1 Reply Last reply Reply Quote 0
              • Emalino EmaleroE
                Emalino Emalero
                last edited by

                Thanks!

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