 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Mar 15, 2008 8:21 pm
[2.20] subregex....sigh |
I found a mistake in the logic of this once I could put it a more extensive set of testing. The problem actually is that the PRUNE causes the pattern to reset and the start point of the match to move 1 character forward. This was causing a pattern such as "\d+" to produce more matches then it should. For example a test string of "1234 5 6 78 9" would produce this series of matches: 1234 234, 34, 4, 5, 6, 78, 8, 9. This was not a good thing.
Sadly there is no way for me to shift the linkage between the regex and replacement to keep the calls to the replacing code to a minimum while still having access to the thinking of the regex engine. I treid everyway I could imagine to shift it around, but in the end just had to live with the extra calls and make the logic handle it right. After my changes the above pattern with a sub string of "x" properly produces "x x x x x", changing the pattern to "\d" properly produces "xxxx x x xx x".
A new file with the correections is in the mail. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Mar 17, 2008 5:31 pm |
I received your updated files and will add them to the next version.
I had also noticed this behavior when testing, but I couldn't decide if this was "normal" behavior for regular expressions or not. I definitely agree that your changes make it work more like what I'd expect it to. Thanks! |
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|