Community
    • Login

    delete an empty line after a specific text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 1.3k 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.
    • T Offline
      tonymattina
      last edited by

      If an empty line is preceded by a specific text, then I want to delete it

      …gc Mstem
      [empty line]
      new line…

      I want to end up with
      …gc Mstem
      new line…

      I would appreciate some help.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @tonymattina
        last edited by PeterJones

        @tonymattina

        FIND = gc Mstem\R\K\R
        REPLACE = leave empty
        REPLACE ALL

        the first \R is the newline before the empty; the \K means keep the stuff that went before; the second \R is the newline for the empty line; because of the \K, it keeps most, and just replaces the second newline (and “replace with empty” = “delete”).

        -—

        Useful References

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • Formatting Forum Posts
        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        1 Reply Last reply Reply Quote 3
        • T Offline
          tonymattina
          last edited by

          Thank you very much.
          I found that NP++ finds the empty line after “gc Mstem” and highlights the next line.
          I have tried replace with nothing and it leaves the blank line there.
          So there is something I still do not understand.
          I’m working on it!

          CoisesC 1 Reply Last reply Reply Quote 0
          • CoisesC Offline
            Coises @tonymattina
            last edited by

            @tonymattina said in delete an empty line after a specific text:

            So there is something I still do not understand.

            It is possible that you are victim of a quirk.

            Regular expressions that use \K do not work properly if you try to replace them in Notepad++ one at a time; they only work when you use Replace All.

            1 Reply Last reply Reply Quote 3

            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