Catching (%s) or "" in the same spot?

by Unknown

Back to Mechanic's Corner.

Unknown2005-08-31 04:36:16
I'm trying to make a rift tracking script, so I have this trigger that checks a line of the stuff that you get from IR.

^ ~ (%w)(%s)~ (%w)(%s)~ (%w)$

However, when I have more than 1000 of something, it crashes, cause (%s) doesnt take nothing. Any way to do it good?
Unknown2005-08-31 09:49:22
Using zMUD patterns, you would first of all not put parentheses around the %s, since you don't need to capture the spaces. Secondly, you can use a string list, with the second element being empty.

CODE
^ ~ (%w){%s|}~ (%w){%s|}~ (%w)$


Alternatively, you could use a regular expression, such as this one:

CODE
^ \\ (\\a+)\\s*\\ (\\a+)\\s*\\ (\\a+)$


The two patterns are nearly identical in what they match and how.
Unknown2005-08-31 09:56:14
To explain a bit more, the problem in your pattern are the %s within brackets. %s matches one space or more, so when you have more than 999 of any commodity in the rift, you no longer have a space where your trigger pattern wants at least one.

I think I'd go with the second pattern Zarquan gave you, provided your zMud supports Perl type patterns.