Community
    • Login

    How to find the first space in all lines?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 2 Posters 1.1k Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              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 Offline
                Emalino Emalero
                last edited by

                Thanks!

                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors