rizonesoft / Notepad3

Notepad like text editor based on the Scintilla source code. Notepad3 based on code from Notepad2 and MiniPath on code from metapath. Download Notepad3:
https://www.rizonesoft.com/downloads/notepad3/
Other
5.09k stars 335 forks source link

Regex find and replace works incorrectly when using ^ (beginning of line anchor) #3551

Closed WalterGR closed 3 years ago

WalterGR commented 3 years ago

Using Notepad3 (x86) v5.21.227.1

I need to remove the first character of some number of lines, either the lines in the selection or the entire document - the behavior is the same for both.

Search string: ^.
Replace with: 
Options checkmarked in search dialog:
  Regular expression search

Document before replace:

abc
def

Expected document after replace:

bc
ef

Actual document after replace:

   
   

That is to say, each line has had all of its characters removed.

It would seem that the first character of a line is matched, then removed, and then the match is performed again without advancing to the next line.

hpwamr commented 3 years ago

Hello @WalterGR , Your Regular Expression seems not complete ?

2021-08-07_092956

But Notepad3 also offers other easier ways!

2021-08-07_093618

2021-08-07_093842

RaiKoHoff commented 3 years ago

@WalterGR is right, searching for the next pattern matching should start after last replace position and not at replace position 🤔

RaiKoHoff commented 3 years ago

Yes, this case needs a special handling in multi replacement loop to move forward to next match. IMO Notepad++ is wrong too in this special case: Correct: All Occurrences (& counts) shown before replacement, should be replaced, neither more nor less 🤔

RaiKoHoff commented 3 years ago

PR #3552 will fix this case (and one related special case using the regex line begin pattern with zero-length replacement). Not sure if all thinkable special cases are caught too 🤔

hpwamr commented 3 years ago

searching for the next pattern matching should start after last replace position and not at replace position 🤔

IMO Notepad++ is wrong too in this special case....

Hi @RaiKoHoff , For Your Information:

hpwamr commented 3 years ago

PR #3552 will fix this case

Hello @WalterGR ,

Feel free to test the "BETA/RC PortableApps", version "Notepad3Portable_5.21.807.1_beta.paf" or newer, see 1st list in issue #1129.

"Notepad3Portable BETA/RC PortableApps" version can be used with or without ".7z" extension.

Also, feel free to test the "BETA/RC Setup", version "Notepad3_5.21.807.1_beta_Setup" or newer, see the 2nd list in issue #1129.

Comments and suggestions are welcome... 😃

WalterGR commented 3 years ago

Yep, issue is fixed!

Thanks so much for the amazing turnaround!