Search and replace help



  • 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?



  • @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>.



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

    Replace “<html tag>”

    With “contents of clipboard <html tag>”



  • @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



  • 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”…



  • Notepad


Log in to reply