|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Tue Mar 25, 2008 9:52 pm
[2.21] Two bugs in the new %subregex (naked alternation & empty return) |
EDIT: Original bug was reported against 2.20, when Vijilante's new subregex code went in.
Since I've been fiddling with %subregex recently, here are two things I've found:
#1: The new %subregex code fails to match a naked alternation:
Code: |
#show %subregex("abc def ghi jkl mno pqr","a|g","X") |
just gives a blank line. However, putting the alternation in a capture group, works fine:
Code: |
#show %subregex("abc def ghi jkl mno pqr","(a|g)","X")
--> Xbc def Xhi jkl mno pqr |
The naked alternation matched correctly in 2.18.
#2: Note also that %subregex() now returns an empty string when there are no matches! It should instead return the original string, unmodified (and did so in 2.18).
To show that this has nothing to do with bug #1:
Code: |
#show %subregex("abc def ghi jkl mno pqr","acb","X") |
just gives a blank line. |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you!
Last edited by JQuilici on Sat Mar 29, 2008 4:25 pm; edited 1 time in total |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Mar 26, 2008 12:26 am |
#1 I am still seein this with the code I have already changed for 2.20 and will have to trace this problem more thoroughly. Since I have been looking at the compiled pattern structure recently I can tell you that the naked alternation hasn't changed in terms of the PCRE so it should still be supported. Right now it looks like it isn't matching and the same thing would affect any trigger that has a naked alternation. Hence the blank return.
2. Just a bit of a problem in the coordination between Zugg and I. It can be fixed rather simply by changing 1 line. Since I am in the middle of working on the optimisations I said had to be done in another topic I will just post the change and hope Zugg notices. Line 144 of VijSubRegex.pas change from "Result:='';" to "Result:=s;". |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Mar 28, 2008 11:27 am |
I figured out the cause of the naked alternation not working. The general gist of it is that the 'a' was matched but the substitution code was connected on the 'g' branch of the alternation. This meant my substitution code never got called.
Since I am working at writing some stuff to integrate with patterns for my member idea I will also do some coding to handle connecting my substitution on each branch of the alternation. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Sat Mar 29, 2008 4:24 pm |
Still present in 2.21. Not surprising, since I didn't see anything on the version history about this.
Vijilante wrote: |
I figured out the cause of the naked alternation not working. The general gist of it is that the 'a' was matched but the substitution code was connected on the 'g' branch of the alternation. This meant my substitution code never got called. |
If this is the problem, I am surprised that neither of the matches got replaced. That pattern on that string should have matched once on each branch...so why did your code not get called when the 'g' branch matched? |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
|
|