|
jtown84 Novice
Joined: 09 Oct 2007 Posts: 36
|
|
_________________ Aardwolf |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Wed Apr 02, 2008 9:54 am |
As in allowing the character '*' rather than the pattern match *?
Sure, use ~* |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Apr 02, 2008 10:11 am |
If you mean allowing wildcards, then no. You need to use a regex instead.
|
|
|
|
jtown84 Novice
Joined: 09 Oct 2007 Posts: 36
|
Posted: Wed Apr 02, 2008 10:17 am |
shake, I have a trigger
the Var BSMessages is a String list
Code: |
You lunge at * with *|You stab at * with *|You try to crush * with *|You flail at * with *|You attempt to hit * over the head with *|You try to gash * with *|You thrust * at *|You swing hard at * with *|You attempt to bury * deep into * back |
Whats the best way to get that to work.. note the * are multiple words that change. |
|
_________________ Aardwolf |
|
|
|
jtown84 Novice
Joined: 09 Oct 2007 Posts: 36
|
Posted: Wed Apr 02, 2008 10:20 am |
Fang Xianfu wrote: |
If you mean allowing wildcards, then no. You need to use a regex instead. |
bleh:P I dont know regex
I thought there might be a way since you could in zMud. :P |
|
_________________ Aardwolf |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Apr 02, 2008 10:34 am |
Nope, but changing that particular pattern will be easy - just change * to .* and {} to () and it should work fine. You could even just paste your pattern into a trigger and click the "Convert to Regex" button.
I'm sure someone's going to mention how slow that'll be, so I'll pre-empt them - using lots of .*s (and *s in zScript patterns, for that matter) like that will be very slow to match and to fail to match. If you care about that, take the time to read through some regex guides and use some of the more specific wildcards to speed up the match. You could also use more-specific zScript wildcards and then use Convert to Regex if you want.
Also, if you're not going to be using #sub, you don't need a * at the end of the line. I'll assume that you are using #sub, but if you're not, you can get rid of them and remove the end-of-line anchor.
I do wonder why the option from zMUD hasn't been carried over, though. I never had any problems with it, so perhaps it's just an oversight. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Apr 02, 2008 1:36 pm |
have you considered a multiple annonymous stringlist trigger?
#TR{{you stabe at|you try to crush|you attempt to hit|ect} * {with|deep into|ect}} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Wed Apr 02, 2008 4:55 pm |
If BSMessages is exactly as you say, there may not be a reason to use any wildcards at all - you're not saving the results of the match anyway. If you don't HAVE to check past the first * to tell whether you want to match the string, then don't bother.
Thus, you could just use a pattern like
with BSMessages having the value
Code: |
lunge at|stab at|try to crush|flail at|attempt to hit|try to gash|thrust|swing hard at|attempt to bury |
Faster yet would be to skip BSMessages and use a single regex, in which you rearrange the strings to group common substrings and use atomic groups to speed up rejection of non-matching lines:
Code: |
^You (?>try to (?:crush|gash)|attempt to (?:hit|bury)|(?>lunge|stab|flail|swing hard) at|thrust) |
That will match all of the same lines, with no wildcards, and should be somewhat faster.
Note that both of these patterns would also match some additional lines that the original would not (e.g. 'You attempt to hit yourself' would fail in the original, because there's no 'over the head with' later in the line), so do a sanity check to see if any such lines would cause a problem.
Also note that I wrote those patterns off the top of my head, so I haven't tested them extensively. YMMV. |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
jtown84 Novice
Joined: 09 Oct 2007 Posts: 36
|
Posted: Wed Apr 02, 2008 6:31 pm |
This is what i did last night
Its not what i wanted to do because now i #gag and #say, vs just subbing it.
But it works
Thanks for all the help
Code: |
^{You lunge at|You stab at|You try to crush|You flail at|You attempt to hit|You try to gash|You thrust|You swing hard at|You attempt to bury} |
|
|
_________________ Aardwolf |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Fri Apr 04, 2008 12:38 am |
If you want to sub it just do like JQ did above.
Code: |
^You (?>try to (?:crush|gash)|attempt to (?:hit|bury)|(?>lunge|stab|flail|swing hard)|thrust) [^.]*\.$ |
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Apr 04, 2008 12:48 am |
Er... except [^.] is pretty pointless since it's not going to match anything :S
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Apr 04, 2008 1:56 am |
Inside of a class the period is treated at a normal character. The rules for regex classes are somewhat convoluted, the only character that maintains the exact same meaning, as outside the class construct, is the backslash. [^.]* will properly match all characters that are not a period.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Fri Apr 04, 2008 2:40 am |
Right, the negated character class will match everything from from the atomic group to the end of the line period that isn't a "period". The difference is negated character class doesn't backtrack at all and is faster. Sure you can use ".*" just as well, but even that still backtracks once. I just prefer using the negated character class in certain instances.
http://www.regular-expressions.info/repeat.html |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Apr 04, 2008 10:25 am |
Ohhh, yeah. I'd forgotten that - I was remembering how \w and whatnot remained the same.
|
|
|
|
|
|