Community
    • Login

    delete an empty line after a specific text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 363 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.
    • T
      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
        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
          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
            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
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors