Need a script

by Hajamin

Back to Mechanic's Corner.

Unknown2006-01-31 18:54:28
In my experience, the regular expression that Avator posted (or something similar that uses \\bword\\b) is more reliable then the zMUD expression using %q. The %q doesn't seem to match all word boundary characters.
Gwylifar2006-01-31 21:26:56
I'm pretty sure if you put in %q and then convert to regex it will turn out that it was \\b all along.
Unknown2006-01-31 21:57:15
You have a valid point there, but the conversion from zMUD pattern to regular expression is not perfect. It chooses the closest approximations to pattern wildcards. I'm still not convinced that the two are exactly equivalent. The documentation for %q just says that it matches any punctuation plus the start and end of a line. Documentation for \\b says that it matches any non-word character. They're close to being the exact same thing, but not quite. (Just depends on Zugg's definition of punctuation then, I guess.)
Strakc2006-01-31 23:04:38
Is it possible to setup the trigger to catch this ele and not bracelet. just wondering
Unknown2006-02-01 06:56:53
QUOTE(Gwylifar @ Jan 31 2006, 09:26 PM)
I'm pretty sure if you put in %q and then convert to regex it will turn out that it was \\b all along.
252312



But why use %q when it's going to be converted to some regex equivalent somewhere along the way? Why not just use \\b from the start and save the client some work and yourself some doubts? smile.gif
Gwylifar2006-02-01 16:07:10
Just because 99% of the time it's easier to write the simplified patterns (and to understand them later when you're looking at a trigger and saying, "why doesn't this work anymore, and why did I write it this way?") and they work just as well. It's the 21st century, let your computer save you more work than it causes you once in a while, it's powerful enough. And use the hairier and more powerful ones when you need them, too. Best of both worlds.
Unknown2006-02-01 18:36:30
Nah, the % ones give me enough trouble in Lua. I guess it's just about what you are more used to. Plus I don't have to hold down the Shift key to put a \\ in, so I guess it's a matter of convenience also. tongue.gif
Strakc2006-02-01 18:47:21
QUOTE(Strakc @ Jan 31 2006, 06:04 PM)
Is it possible to setup the trigger to catch this ele and not bracelet. just wondering
252345



Please heeelp?
Unknown2006-02-01 18:52:17
Ah, I finally got what you meant, kind of.If you just want to match a single word "ele", then it's the same thing: "\\bele\\b" or "%qele%q".

If you want to match "ele" as part of any word but "bracelet" then it's considerably more difficult, and I'll need to fish out my "Grace flings a Lover's tarot at you." trigger. So before I do, clarify which one it is exactly?
Strakc2006-02-01 19:59:48
I want it to match Ele but not brac-ele-t or c-ele-st the way it is, it catchs ele in any word, i dont want that. I want it to match just the word ele and nothing else.
Unknown2006-02-01 20:07:18
Then the first suggestion:

#REGEX {\\ble\\b}

or #TR {%qEle%q}

I don't know how to set Zmud triggers case incensitive or do options in them, so the second pattern will probably match "Ele" but not "ele".
Asarnil2006-02-01 20:51:47
No, the second option picks up both from memory - at least it always has when ive been too lazy to capitalize peoples names on my lists. It just only picks up Ele/ele with punctuation or spaces before and after it which cuts down on the false positives.
Strakc2006-02-01 21:29:25
Your not getting my point i want to catch ele, but it catches ele in words ot just ele. It will do things like this celest and bracelet see i want to catch ele as a single word not in other words..
Daganev2006-02-01 21:56:45
The way in zmud to do the grace flings a tarot card is to do "(%w){-grace} flings a tarot card"

or something like that...

And Strakc, I should have a trigger, one that starts with the word CITIZEN and one that starts with the word ENEMIES that should do ele but not celest.
Unknown2006-02-02 06:04:47
QUOTE(Strakc @ Feb 1 2006, 09:29 PM)
Your not getting my point i want to catch ele, but it catches ele in words ot just ele. It will  do things like this celest and bracelet see i want to catch ele as a single word not in other words..
252725



Either of the triggers I posted will catch ele but not bracelet or celest. Here's proof for the first trigger:

bracelet
ele
cele
celest
mellet
,elendor
,ele(
Asarnil2006-02-02 06:56:58
Avator - for the triggers you posted, at least from memory he wanted to pull them from a variable string list, in which cast it would be %q{@variablename}%q or its regex equivalent. the brackets around the name in the #trigger format tells it to apply the colour to all the words in the string list.
Unknown2006-02-02 07:29:25
Ah, but we've covered that before. thumup.gif
Strakc2006-02-02 15:45:17
#REGEX \\b(?:@CommuneEnemies)\\b is how I got it to work.