Community
    • Login

    Need help with a search and replace...

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 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.
    • Jeramey BeckJ Offline
      Jeramey Beck
      last edited by Jeramey Beck

      I have data that looks like this:

      1 Bergey,Ben 8 Great Strides 11:26.91 1

      I need to do a large search and replace so that my data looks like this:

      1|Bergey,Ben|8|Great Strides|11:26.91|1

      This will allow me to then import my data into Excel and get everything in the proper columns for data manipulation.

      Any help would be greatly appreciated.

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

        With only 1 example I had to work with, I can only hope this will work for you. It did for me, even when the 1st, 2nd and last numbers were longer than 1 character.

        So
        Find what: ^(\d+)\s(.+?)\s(\d+)\s(.+?)\s([.0-9:]+)\s(\d+)
        Replace with: \1\|\2\|\3\|\4\|\5\|\6

        So this is a regular expression, that means you need to operate in “regular expression” search mode in the replace window (Ctrl-H). Also have ‘wrap around’ ticked. You can run it as single mode replace until sure you are happy with the results. Then click on replace all button and it will complete the changes for you in the current file.

        Let us know if you require any changes, possibly due to other records not exactly fitting the example well enough to be picked up by my regex.

        Terry

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

          I have another regex, this one is possibly a better option as I noticed all your instances of putting the ‘|’ character had either a number before or after.

          So
          Find what: \h(?=\d)|(?<=\d)\h
          Replace with: \|

          So as I said it will only deal with spaces that have a number on either side of it. Therefore it leaves the one alone in (as your example says) “Great Strides”

          Terry

          1 Reply Last reply Reply Quote 1

          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