Notepad3
Notepad3 copied to clipboard
search/replace regex issue
Using 5.21.227.1
Test: wrap space-separated words with { and }
Search string used: ([^ ]+) Replacement used: {\1} Options set: Regular expression search
Text before replacement:
cats dogs
birds fish
Text after replacement:
{cats} {dogs
birds} {fish}
Expected:
{cats} {dogs}
{birds} {fish}
Your search string says: "match all characters except blank" one or more times.
This means including line-break characters. On turning on Menu -> View -> Show line Endings ,
you can visualize what is selected (if Mark Occurrences is active).
Than you will be able to understand that the result is completely correct.
Your expectation needs another search expression, e.g. (\w+)
My apologies, you are correct. Can I blame my expectations on vscode?
In vscode performing this test search/replace produces the (wrong) result. It says there are 4 occurrences and performs 4 replacements. I'd say there's something wrong -- or at least very unusual -- with it.
I then tested against textpad, sublime, notepad++, editpad, and adobe brackets; they all produce the (correct) result, performing 3 replacements. So notepad3 is in good company!
I'll note too that brackets was somewhat unusual: it reported 4 occurrences but then performed 3 replacements (!?).
Thanks for all your work with Notepad3.
The occurrences (and replacement) counting can be improved!
@np3fan : Please help me to reproduce the "4 occurrences but then performed 3 replacements" by detailed workflow description. Thank you in advance.