|
Mondor Novice
Joined: 26 Nov 2008 Posts: 33
|
Posted: Tue Dec 16, 2008 5:10 pm
[3.03] Bug when using '?:' prior to '$var:' in regex trigger pattern |
I think I have encountered this in earlier versions too. I was not able to find any earlier posts addressing this.
If I have a trigger pattern of the form
"He filed ($pronoun:this|that) bug with the (?:forum|circular file)...." then I am able to use $pronoun in my trigger script if the match occurred. The Trigger Tester shows that I've captured 'this' or 'that' in the $pronoun variable on a match and the trigger works as advertised.
If a ?: construct proceeds any $var: constructs in the pattern, the $var variables are not assigned on a match
"He filed (?:this|that) bug with the ($proper_channels:forum|circular file)...."
1) will show either 'forum' or 'circular file' assigned to %1, not $proper_channels in the Trigger Test on match.
2) the script will compile with no errors, BUT
3) $proper_channels will contain NULL (I think) when referenced by the trigger script
Thanks |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Dec 16, 2008 6:09 pm |
Looks like something is just counting parenthesis and not checking the the ?: for non-stored items. I've added this to the bug list.
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Dec 17, 2008 6:00 pm |
Maybe it would be a good idea to connect the regex named capture syntax directly to local variables. The interface provides a complete list of the names when a regex is compiled, and named captures do not allow duplicate names by default.
|
|
_________________ 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: Wed Dec 17, 2008 6:03 pm |
That's how I thought I was doing it already, but I'll need to look at the code to see what is going wrong with this.
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Dec 17, 2008 6:49 pm |
I never actually tested whether you connected the named captures since I didn't see anything in the version history indicating it. As far as I know the last interface bug involving named captures was found and fixed for 3.02. I doubt you could have properly connected them prior to that since I still hadn't gotten the interface that generates the full list of names perfected until then. I would have to dig through my list of change logs to be sure, but I don't think I added generation of a names list to the interface until 2.30.
Anyhow, the regex syntax for a name capture is "(?<name>pattern stuff)". This would add "name" to the list of names, and these are case sensitive even when the pattern is not; in fact the is no easy way to remove case sensitivity from the names. There are some other syntaxes supported for named captures, but the above is the Perl standard. The interface provides Names as a | seperated string list of each name. They are sorted into alphabetacal order. An asscoiated array of capture number is available if you want to use your own look up method or create a futher lookup table, otherwise the infterface will use the default binary tree search method when asked to retrieve a value for a named capture. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums
Last edited by Vijilante on Thu Dec 18, 2008 7:10 pm; edited 1 time in total |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Dec 17, 2008 10:39 pm |
Nope, I looked at the code and CMUD is pulling out the named patterns itself and ignoring the (?:). I'll add this to the bug list and try to use the named capture info returned by the regex routines themselves, or will just fix it so it handles the ?: stuff properly.
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Dec 18, 2008 7:15 pm |
Sorry about any confusion, I forgot to disable HTML in my previous post so the forum was eating some stuff. It is corrected now.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
|
|