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!



  • @Mark-Gray ,

    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 newline is 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)



  • @PeterJones Thank you SOOO much!


Log in to reply