|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Sat Apr 30, 2005 12:51 am
Placing a variable in a class using regex pattern match? |
Hopefully an easy answer to this...
I've started playing with regular expressions a little, but can't seem to place variables inside specific classes once they're matched.
Normally I'd have made a trigger:
Code: |
#trigger {^You have (%d) out of (%d) health remaining.$} {#variable chealth {%1} {} "Standard|score";#variable mhealth {%2} {} "Standard|score"} "Standard|score" |
But the regex equiv (I think) is:
Code: |
#REGEX {^You have (?chealth:\d+) out of (?mhealth:\d+) health remaining\.$} {} "Standard|score" |
So the top example places the variables into a specific class, whereas the lower example doesn't.
I tried without success to change the regex to the following:
Code: |
#REGEX {^You have (?Standard|score|chealth:\d+) out of (?Standard|score|mhealth:\d+) health remaining\.$} {} "Standard|score" |
Problem is that sometimes I get more than one variable with the same name if I'm opening and closing classes as I go, and trying to find a quick way of keeping things tidy
Thanks in advance. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sat Apr 30, 2005 4:47 am |
use #variable.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Sat Apr 30, 2005 11:17 am |
So it's a no? ;)
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
hav Wanderer
Joined: 05 Oct 2004 Posts: 61 Location: Riga, Latvia
|
Posted: Sat Apr 30, 2005 5:58 pm |
Create variable beforehand yourself in the appropriate class. Then use that second trigger. (?varname:\d+) works like a charm.
|
|
|
|
Pega Magician
Joined: 08 Jan 2001 Posts: 341 Location: Singapore
|
Posted: Sun May 01, 2005 4:00 pm |
This might work,
Code: |
(?\classname\subclassname\variablename:\d+) |
A Regex equivalent of this,
Code: |
#trigger {^You have (%d) out of (%d) health remaining.$} {#variable chealth {%1} {} "Standard|score";#variable mhealth {%2} {} "Standard|score"} "Standard|score" |
is ...
Code: |
#REGEX {^You have (\d+) out of (\d+) health remaining\.$} {#variable chealth {%1} {} "Standard|score";#variable mhealth {%2} {} "Standard|score"} "Standard|score" |
A non-Regex equivalent of this,
Code: |
#REGEX {^You have (?chealth:\d+) out of (?mhealth:\d+) health remaining\.$} {} "Standard|score" |
is ...
Code: |
#trigger {^You have &%d{chealth} out of &%d{mhealth} health remaining.$} {} "Standard|score" |
MUD = Timewaster |
|
|
|
|
|