Find/Replace Help
-
I have a big text file I am trying to clean up so it can be imported to a database. Some of the lines are broken into two lines.
I have a regular expression that finds some of the lines pretty accurately. They are less than 45 characters and and with an asterix character
^.{0,45}(\*)$I’d like to delete the LF character at the end of these lines only. Is there a way to do this with find/replace? Thanks in advance!
-
Yes.
Move the parentheses a little, and change the
$marker to\R, so it will actually grab the newline sequence:- FIND =
^(.{0,45}\*)\R
REPLACE =$1
MODE = regular expression
make sure. matches newlineis off (or prefix the FIND with(?-s))
This puts the 0-45 characters and the asterisk in group1, then grabs the newline (LF or CRLF) that occurs. The replacement only keeps the 0-45 characters plus asterisk.
If you want to delete the asterisk as well as the newline, then FIND =
^(.{0,45})\*\R(so that the asterisk is not in group1 anymore, and thus not kept in the replacement) - FIND =
-
@PeterJones Thank you SOOO much!
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