Community
    • Login

    add text before the 2nd last space in each line?

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 2 Posters 1.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.
    • gifthubbroG Offline
      gifthubbro
      last edited by

      I want to add a comma before the 2nd last time in each line of text in notepad ++, heres an example if what I mean : house, Road, westworld, Co. London H509 50565

      so I want to add the comma after London, to make it appear like this: house, Road, westworld, Co. London, H509 50565

      thanks!

      1 Reply Last reply Reply Quote 0
      • Terry RT Offline
        Terry R
        last edited by

        @gifthubbro said in add text before the 2nd last space in each line?:

        heres an example if what I mean : house, Road, westworld, Co. London H509 50565

        Are you able to confirm that the last piece β€œH509 50565” exists on all lines. Obviously not those exact characters, but that there are 2 words (a word here is defined as a string of non-blank characters) that need separating by adding the comma on every line. Without that assumption is might be difficult to decide where to place the comma.

        Terry

        gifthubbroG 1 Reply Last reply Reply Quote 0
        • gifthubbroG Offline
          gifthubbro @Terry R
          last edited by

          @Terry-R thats right all the lines are two words, where I need to insert a comma before these last two words

          1 Reply Last reply Reply Quote 0
          • Terry RT Offline
            Terry R
            last edited by Terry R

            @gifthubbro said in add text before the 2nd last space in each line?:

            so I want to add the comma after London

            So that being true, try this.
            Replace function:
            Find What:^(.+)((\h\w+){2})$
            Replace With:\1,\2

            See if that works for you.

            Terry

            gifthubbroG 1 Reply Last reply Reply Quote 3
            • gifthubbroG Offline
              gifthubbro @Terry R
              last edited by

              @Terry-R thanks that worked!

              1 Reply Last reply Reply Quote 2

              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