|
haiku Wanderer
Joined: 19 Nov 2004 Posts: 70
|
Posted: Sat Sep 15, 2007 4:07 am
quick pattern matching question |
here's the current trigger pattern:
Code: |
^~[{| } %d %w %w {L| } ~] (%w) %s (%d)/(%d) %s %d/%d %s %d/%d %s %d$ |
It does the job nicely.
That only works though, if I'm introduced to the person.
Here's some sample mud text:
Code: |
[ 28 Mon Trl ] Groob 387/411 315/315 109/144 3020373
[ 10 Mag Hum ] a female human 64/95 14/197 75/75 145968
|
What I thought would work was this:
Code: |
^~[{| } %d %w %w {L| } ~] {(%w)| a (%w) %w} %s (%d)/(%d) %s %d/%d %s %d/%d %s %d$ |
I wanted to grab that second word - in this case female - such that I could target them like I target Groob.
The code seems to compile, and it doesn't throw an error message, but it does nothing when I do a
, whereas my current trigger will show Groob 387 411 with the same trigger.
Personally, I think that the
part should work, but it obviously isn't. Any ideas? |
|
|
|
DeReP Adept
Joined: 14 Jun 2003 Posts: 222 Location: Chile
|
Posted: Sat Sep 15, 2007 6:39 am |
How about
Code: |
^~[{| }%d %w %w {L| } ~]%s{(%w)|a%s(%w)%s%w}%s(%d)/(%d)%s%d/%d%s%d/%d%s%d$ |
Perhaphs leaving that space before the "a" and after the "]" (making it a double space) would make your trigger not to fire at all. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Sep 15, 2007 1:41 pm |
Use a fixed width pattern instead. Then parse it with %trim, %word, and %numwords.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Sep 15, 2007 1:49 pm |
Wildcards don't work inside the {one|two} syntax. You can use a regex instead.
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Sat Sep 15, 2007 6:38 pm |
Code: |
^\[ *\d+ \w+ \w+ +L? \] (?:a )?(\w+) [\w ]+ (\d+)/(\d+) +\d+/\d+ +\d+/\d+ +\d+$ |
Regex. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Sep 16, 2007 9:09 am |
One tiny change to get the captures working properly:
Code: |
^\[ *\d+ \w+ \w+ +L? \] (?:a )?(\w+) [\a ]+(\d+)/(\d+) +\d+/\d+ +\d+/\d+ +\d+$ |
This also didn't actually match your test lines, haiku, because they have a space at the end. You might need to add that in. |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Sun Sep 16, 2007 3:32 pm |
Fang: What's \a in CMud? My cheat sheet tells me it's a bell/alarm character, and obviously it's not functioning like that.
Although my original pattern works fine, too, on both examples. At least according to the test trigger box as well as the RegEx Coach. (I didn't include space at the end based on the original trigger which apparently worked.) |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Sun Sep 16, 2007 3:45 pm |
I think it's a confused %a that doesn't convert to \a (should be \w or [a-z]), but maybe CMUD doesn't use the standard \a as the bell character?
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Sun Sep 16, 2007 4:51 pm |
I tried the \a in the pattern matcher, and it was functioning like [A-z], so not quite like %a and not quite like \w, but I see what he was getting at now--if the name line runs long and you don't get a space between it and the first set of numbers, then you'd need that pattern.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Sep 16, 2007 6:03 pm |
\a is [A-z] like you say. %w is \a+. Don't ask me why %w and %a are the wrong way round - they just are.
|
|
|
|
|
|