Community
    • Login

    Find/Replace Help

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 551 Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          Mark Gray @PeterJones
          last edited by

          @PeterJones Thank you SOOO much!

          1 Reply Last reply Reply Quote 0

          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors