Community
    • Login

    Find and Replace to include <cr><lf>?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 23.4k 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.
    • EP PackE
      EP Pack
      last edited by

      I have a set of text that is in the format of “word1, word2, word3, word4, etc”, and I want to change them to individual lines by replacing the space after the comma with a CRLF so that it will look like this:
      word1,
      word2,
      word3,
      word4,
      etc

      The problem is that I’m not sure what to include in the replace part so that it actually will do that. I’d been using Ultraedit for many years at work, and it did this uneventfully, but alas! I’m retired now, so no longer have access to it.

      By showing the symbols, I can SEE the CR LF at the end of a test line, but apparently I can’t simply copy and paste the comma, space and CRLF into the replace box–tried it but nothing changed, no actual CR occured. Gotta be a way to do this, but like many, I’m pretty new to ++.

      TIA

      Elaine

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by guy038

        Hello, @ep-pack,

        Really not difficult, indeed, with regular expressions !

        • Move to the very beginning of your text to change ( Ctrl + Origin )

        • Open the Replace dialog ( CTRL + H )

        • Type in the regex ,\x20 , in the Find what: box

        • Type in the regex \r\n , in the Replace with: box

        • UN-check the Wrap around box option, if necessary

        • Select the Regular expression search mode

        • Click on the Replace All button

        Et voilà !

        Notes :

        • The syntax \x20 stands for a single space character. You may write a normal space character, instead, in the search zone

        • In replacement, the syntax \r OR \x0D represents the control character Carriage Return ( CR )

        • In replacement, the syntax \n OR \x0A represents the control character Line Feed ( LF )

        Best Regards,

        guy038

        EP PackE 1 Reply Last reply Reply Quote 0
        • EP PackE
          EP Pack
          last edited by

          I’ll give this a shot–I would NEVER have thought regex would work for a replace option in a text editor. Interesting :) Not a big regex user, but do know enough to be dangerous :)

          Thanks!

          elaine

          1 Reply Last reply Reply Quote 0
          • EP PackE
            EP Pack @guy038
            last edited by

            @guy038, worked like a champ!! Thanks!

            It initially didn’t because I hadn’t noticed the “use regex” radio button :) but once I did, hurray!

            elaine

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