Community
    • Login

    Find/Replace Help

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 274 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.
    • Mark GrayM
      Mark Gray
      last edited by

      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!

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Mark Gray
        last edited by

        @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)

        Mark GrayM 1 Reply Last reply Reply Quote 1
        • Mark GrayM
          Mark Gray @PeterJones
          last edited by

          @PeterJones Thank you SOOO much!

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