"[char]*$" S&R regexp doing double-pass?

Joerg Fischer jf505 at gmx.de
Tue Feb 24 19:32:50 CET 2009


> So if for example I started with:
> 1
> 2<space>
> 3<space><space>
> 4<space><space><space>
> 
> And did the above search/replace, I end up with:
> 1;
> 2;;
> 3;;
> 4;;
> 
> To debug, I tried starting with:
> 0
> 1a
> 2aa
> 3aaa
> 4aaaa
> 
> And doing S&R for "a*$" to ";". The way I read this is "replace zero
> or more instances of the character "a" at the end of the line with
> ";".
> ...
> Note BTW that regexp with start-of-line anchor ("^a*" for example) did
> not have any such problems.

What you describe happens by matching in _backward_ direction. Try to search
in forward direction and it behaves correctly. Or you need a non-greedy
start of the pattern, like you noticed.

This is caused by the type of the regex engine implemented into NEdit.
Has to do something with efficiency.

--Jörg


More information about the Discuss mailing list