|
Scirkhan Apprentice
Joined: 14 Sep 2007 Posts: 167 Location: aztx
|
Posted: Thu Dec 13, 2007 1:13 am
Trigger matching with (?) problem. |
#trigger {^(?)(?)(?)(*)} {#show ??? fire}
I'm having a problem with it matching everything. Shouldn't it only be matching lines that start with three spaces?
Why doesn't this work, and what would be something that does work?
Thank you. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Dec 13, 2007 1:43 am |
? matches a single character, whether it's a space or not. Therefore, it'll match spaces, numbers, letters, and based on your trigger pattern, will match every line sent.
If you need to match only three spaces, you could just do:
Code: |
#TRIGGER {^ (*)} {#show fire} |
However, that'll fire on anything with three or more spaces. You could do this instead:
Code: |
#TRIGGER {^(%s)(*)} {#IF (%len(%1)<4) {#SHOW %1 fire}} |
That way, it'll match three spaces only.
Charneus |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Thu Dec 13, 2007 1:49 am |
pattern matching
The ? actually matches any ONE character so basically you are saying many anything that is three or more characters long and store the first three characters in %1 %2 %3 and the rest if any in %4
This will create the trigger that you want. It is much easier to do this sort of thing in a Regex trigger.
Code: |
#REGEX {^\s{3}(\S.*)} {#show ??? fire} |
Edit: I am way too slow...
Oh and if you wanted to show what got matched in the %1 you would do what charn did.
Code: |
#REGEX {^\s{3}(\S.*)} {#show %1 fire} |
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Scirkhan Apprentice
Joined: 14 Sep 2007 Posts: 167 Location: aztx
|
Posted: Thu Dec 13, 2007 3:22 am |
Thank you both very much, very very helpful and useful. the %length (command?) was definitely something i was looking for.
I have learned a little bit of Regex, which means I understand I understand! what you posted Arminas :) just more drive to learn it more fully.
I hope I can have another question answered, I save %line2 to a variable to tag room names, put sometimes my prompt is in front of a room's name. Can I strip my prompt out of a variable? Even a better way to use #sub, or %cr would do, as long as i can save the room name without my prompt.
[ (%d)hp (%d)mp ] The room name
(three spaces)This is the paragraph multi-line.
-I have done pretty well tagging and configuring the mapper, much so to what I want. Except a few things. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Thu Dec 13, 2007 5:08 pm |
I'm not where I can really test this but this is a way to handle that problem.
Code: |
#if (%match(%line2,"~[ %dhp %dmp ~]%s([A-Z]*)",rName)!=1 ) {rName=%line2}
#Tag Name @rName |
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
|
|