|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Sep 22, 2010 4:09 am
Regex pattern capture not working with record variable stringlists |
I just noticed this, but I'm not sure what version it stopped working in. It's also possible that I'm simply bungling the syntax, but this syntax used to work.
Code: |
(?:[\w '-,]+'s|Your) ([\w ]+) (?:does )?{@dam_set.type}
|
Is required to match:
Yasan's slash maims Thanatael!
where maims is the damage type and can be any of a number of different things, all listed in a stringlist as the value of the key type in the record variable @dam_set.
The problem is that if I do:
Code: |
(?:[\w '-,]+'s|Your) ([\w ]+) (?:does )?({@dam_set.type})
|
or
Code: |
(?:[\w '-,]+'s|Your) ([\w ]+) (?:does )?{(@dam_set.type)}
|
It no longer matches. This is a problem because the trigger relies on grabbing the damage type and using that information to relay the amount of damage done. This worked just fine as:
Code: |
(?:[\w '-,]+'s|Your) ([\w ]+) (?:does )?(@dam_type)
|
but I decided to consolidate variables and put the contents of dam_type into dam_set, under the key of type. I see no reason why this shouldn't work, can it be fixed?
Edit: Further info, dam_type is a record variable itself, with the keys being the type of damage (maims, scratches) and the values being the numerical value of damage. |
|
|
|
GeneralStonewall Magician
Joined: 02 Feb 2004 Posts: 364 Location: USA
|
Posted: Wed Sep 22, 2010 6:15 am |
Not quite the answer you're looking for, but have you checked if %db() works? I assume it does.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Sep 22, 2010 1:24 pm |
Inside the trigger pattern? I never considered it, it's a possibility.
Edit: Tried, didn't work |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Sep 22, 2010 4:35 pm |
Remember that to use embedded function calls in a trigger pattern, you need to use two % characters, so it would be %%db(). But I'll try playing with your example of a nested string list to see what's wrong. Your original pattern should have worked.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Sep 22, 2010 4:37 pm |
Btw, you realize that the {@list} syntax for matching a list is only for the normal zScript pattern syntax, right? It looks like you are using a RegEx pattern. You can't use {@list} in a RegEx pattern like that. There is no way that syntax "used" to work.
In any case, I just tested the following:
Code: |
list = {Zugg|Chiara}
#ADDKEY db key @list
#TRIGGER {test {@db.key}} {#SHOW fired} |
and I confirmed that this does not work. Looking at the Compiled Pattern, the parser is not doing a DOT operation and is just concatting the ".key" string. So I've added this to the bug list. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Sep 22, 2010 5:29 pm |
Thanks Zugg, and I was unaware that {} was only for zScript. I know that the regex used is modified somewhat to work with CMUD, no? So I just assumed that I needed to use {} since that was the standard stringlist syntax now, it's good to know that it isn't the case with regex.
On the topic of reformatting, I still haven't noticed anything major or reproducible |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Sep 22, 2010 7:31 pm |
Well, if it's not documented on a Regular Expression help site, then CMUD isn't going to be any different. A RegEx pattern in CMUD uses strict RegEx syntax...there aren't any "enhancements" for CMUD-specific stuff like string lists.
In any case, the bug was with using a @var.key reference within a {} list in a zScript pattern. This is fixed for the next update. |
|
|
|
|
|