Community
    • Login

    Search and replace

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 2.1k 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.
    • Helloiam ThomasH
      Helloiam Thomas
      last edited by

      i cannot fix the regular expressions for that :/

      Suppose you have this text:

      some text [1 Box]
      somer other text [200 Boxes]
      1 Comments
      200 Comments

      i would get this text:

      some text
      some other text
      Comments
      Comments

      (Value 1<) Thank you.

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Parpaluck209P
        Parpaluck209
        last edited by

        See the last post (5/23/17) in this thread:

        https://notepad-plus-plus.org/community/topic/13823/replace-function/47

        Npp can’t do it automatically by copy-and-paste. You need add \r\n at the end of each line in the text to Replace with, then delete the EOLs.

        Several other editors accept direct copy and paste in the replace-with box, be it CR+LF, LF or combination of both. They are probably written in C++. But I think it can be done in any language since CR and LF have the same codes.\r\n\r\nDon is busy now with other issues in 7.4.1. I saw there are problems with replacing again in several open files.\r\n

        1 Reply Last reply Reply Quote 0
        • Claudia FrankC
          Claudia Frank @Helloiam Thomas
          last edited by

          @Helloiam-Thomas

          from the given sample you can use two simple regex to get the result.
          First, to get rid of the text encased by[ ]
          find what:

          \[.*?\]
          

          and replace with nothing.
          To get rid of the numbers
          find what:

          \d+
          

          and replace with nothing.
          If there are other numbers in your text which should be kept, that you might use

          \d+\s+(Comments)
          

          and replace with

          $1
          

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • Parpaluck209P
            Parpaluck209
            last edited by

            @Helloiam-Thomas

            The easiest way, without regex:

            1. Select the bloc you wanna replace and press Ctrl+H. Npp fills the Find what box automatically, with the proper codes inserted (although invisible, unless you try Find in files first; the results panel will show the Find string with the \r\n codes inserted properly).

            2. Select the text to Replace with. Unfortunately, Notepad++ does NOT fill the box with the proper codes automatically. You need insert the \r\n codes at the end of each line manually.

            some text**\r\n**
            some other text**\r\n**
            Comments**\r\n**
            Comments**\r\n**
            \r\n
            (Value 1<)\r\n

            Go to the end of each line and press Delete (it deletes the EOL codes, LF or CRLF).

            1. It is a one line bloc now. Select the new bloc of text and paste it into the Replace with box:

            some text**\r\nsome other text\r\nComments\r\nComments\r\n****\r\n***(Value 1<)*\r\n

            Voilà!

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