Regex replace all \< with a word (add prefix for all word) not works as expected:
Open SciTE type the word "hello", after replace all with "With", "hello" become "WithhWitheWithlWithlWitho".
however add suffix for all word by replace \> works.
summary: Regex bug for replace all '/<' with a word --> Regex bug for replace all '\<' with a word
Description has changed:
Diff:
--- old+++ new@@ -1,4 +1,4 @@-Regex replace all `/<` with a word (add prefix for all word) not works as expected:+Regex replace all `\<` with a word (add prefix for all word) not works as expected:Open SciTE type the word "hello", after replace all with "With", "hello" become "WithhWitheWithlWithlWitho".
however add suffix for all word by replace `\>` works.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A problem here is that RESearch::Execute treats the start of search as a line start and thus word start. It should probably be passed the line start value as a parameter or be able to discover it.
I have changed the title and description from /< to \< as it didn't make sense otherwise. please advise if /< was meant.
👍
1
Last edit: Neil Hodgson 2021-09-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Patch to sync match_not_bol and match_not_eol, this fixed original problem except finding \> or \>$ at line end (will needs another patch similar to RESearch-EOW-atLineEnd-1013.diff).
reverse search test cases for std::regex are omitted due to current MatchOnLines() treats empty match as failure.
Just following after switch in RESearch::Execute():
if(ep==NOTFOUND){/* similar to EOL, match EOW at line end */if(endp==lineEndPos&&*ap==EOW){if((ap[1]==END||((ap[1]==EOL&&ap[2]==END)))&&iswordc(ci.CharAt(lp-1))){lp=endp;ep=lp;}else{return0;}}else{return0;}}
so it's independent of other changes except test cases.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Another bug:
^\<can find words at line start, but\>or\>$can't find words at line end.The search bug was fixed, maybe in 5.1.1 with
8873 (80d3b0c2b86a) Extract word edge detection to prepare for fixing bug..Sorry, not yet fixed. however,
\w\>or\w\>$does find the last letter.Diff:
A problem here is that
RESearch::Executetreats the start of search as a line start and thus word start. It should probably be passed the line start value as a parameter or be able to discover it.I have changed the title and description from
/<to\<as it didn't make sense otherwise. please advise if/<was meant.Last edit: Neil Hodgson 2021-09-20
how about change
BOLandEOLto only match real line start and end likeMatchFlags:Patch to sync
match_not_bolandmatch_not_eol, this fixed original problem except finding\>or\>$at line end (will needs another patch similar toRESearch-EOW-atLineEnd-1013.diff).reverse search test cases for
std::regexare omitted due to currentMatchOnLines()treats empty match as failure.The code for line end and line start seem intertwined so should be in a combined patch to better understand the scope.
Just following after switch in
RESearch::Execute():so it's independent of other changes except test cases.
The combined patch:
I think there is a duplicated test for
findingEOWon lines 600-603.Removed the duplicated test.
first patch to fix finding
\>or\>$at line end.fix
\<will needs another patch to set line start/end position forBOLandEOL, seehttps://github.com/zufuliu/notepad2/commit/1bfaf31d6e05b99a1dd441854cfb82c3cf6f601e
Committed as [60a4cc] with extra tests for
\>$.Related
Commit: [60a4cc]