Find and Replace to include <cr><lf>?
-
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,
etcThe 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
-
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
-
-
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
-
@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