regex and newlines
-
I wanted to rename a number of files using a batch file in a command-line app. To begin, I wanted to change each line to “ren \1 \1” so that I could work on it. However, Notepad++ included newlines so that it changed each line to “ren \1” on one line, “\1” on a new line. I could not work out how to prevent this, so I tried the same procedure in Sublime Text where it worked as I wanted it to work.
-
I believe that capture group 1 included the newline. Since you only showed us your REPLACE, without showing the FIND, I cannot show you specifically what’s wrong with your FIND that puts the newline in group 1
Useful References
-
@John-Sampson said in regex and newlines:
However, Notepad++ included newlines so that it changed each line to “ren \1” on one line, “\1” on a new line
So if you were using
\1that assumes you were searching in regular expression mode. Then I’m going to assume your find what field also captured the CR and LF characters which are EOL markers. Returning those would likely produce the result you saw.I think you need to post the Find What field you used so we can confirm what you were doing.
Oh, just saw that @peterjones also believes the same.
Terry
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