Community
    • Login

    Search and replace help

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 3 Posters 2.6k 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.
    • Dan LeitchD
      Dan Leitch
      last edited by

      In search and replace I’ve typed (without the quotes)
      “<html tag>.*</html tag>” and pressed find.

      I expected this to find the first instance of <html tag> in the document and the first instance of </html tag> and highlight them and everything in between.

      Didn’t quite work, it found the first instance of <html tag> and the last instance of </html tag> and highlighted near enough the whole document.

      What did I do wrong and how do I make it do what I expected?

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @Dan Leitch
        last edited by

        @Dan-Leitch

        The .* regular expression will match the MOST that it can. Try .*? as that will match minimally, i.e., in your example you’ll get the closest match of </html tag>.

        1 Reply Last reply Reply Quote 0
        • Dan LeitchD
          Dan Leitch
          last edited by

          Thanks, another question, is there a way using search and replace to do this

          Replace “<html tag>”

          With “contents of clipboard <html tag>”

          Scott SumnerS 1 Reply Last reply Reply Quote 0
          • Scott SumnerS
            Scott Sumner @Dan Leitch
            last edited by

            @Dan-Leitch

            It is not possible to do this with stock Notepad++. However, in the spirit of “it’s software, most things are possible”, I think it could be done. Here’s how:

            Using the Pythonscript plugin and the ctypes library, hook into the message processing loop for the Find window’s Replace button. When you detect that the user has pressed that button, get the data out of the clipboard and substitute that for your contents of clipboard string in the replace-with zone (yes, you would use exactly contents of clipboard<html tag> in that zone–the clipboard contents part would be like a “token”…). Then give the new Replace-with zone data to Notepad++ to do the (normal) replace function.

            Easy? No. Doable? Probably. :-D

            1 Reply Last reply Reply Quote 0
            • Scott SumnerS
              Scott Sumner
              last edited by

              Slight edit:

              …and substitute that for your contents of clipboard string in the replace-with zone (yes, you would use exactly contents of clipboard<html tag> in that zone–the contents of clipboard part would be like a “token”…

              1 Reply Last reply Reply Quote 0
              • Anil AniA
                Anil Ani
                last edited by

                Notepad

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