|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sat Jul 28, 2007 10:03 pm
#SUB and words |
To be honest, I'm sure this has probably been answered before. However, with the new search system for zuggsoft, I cannot find anything if it was sitting right in front of me. So, I'm going to ask this question here.
How would I go about just subbing the word as a whole, not if it's contained in part of another word? To clarify things, I'll use this example:
#TRIGGER {myst} {#SUB <send "home;run es;mystsw">MYST</send>}}
Now, it works when MYST shows up on the screen, but it works a little too well. It also triggers when someone says "mystical," changing it to "MYSTical" and creating the link. Any help? Thanks!
Charneus |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Jul 28, 2007 10:19 pm |
Quick note - you can still use the old search. It's under the Site menu at the top.
Your problem is that your pattern's not specific enough. The easiest way to fix it is just by adding a space to the end, and maybe to the start. Then it'll only match "myst" on its own. If the word isn't always followed by a space you might find it worthwhile changing to a regex and using the \b wildcard. \b matches a word boundary - that is, the line between a word and something that's not a word (like a space or a bracket). "\bmyst\b" will match things like "(myst)" or "[myst]" as well as " myst " (but it won't match "myst2" because regexes consider numbers to be part of words as well as letters. Crazy, I know) |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sun Jul 29, 2007 7:02 pm |
Ok. I'll have to look into that, then. Here's another problem regarding #SUB. I suppose it could be fixed in the same way, but sometimes the words end in periods, which does not help me.
I also have the following triggers:
#TRIGGER {Coven} {#SUB {blah blah blah}}
#TRIGGER {Covenent of Mistridge} {#SUB {blah blah blah}}
Don't mind the "blah blah blahs." They're essentially the same as the previous trigger mentioned. The problem with this one is that "Coven" appears in both "Coven" and "Covenent," and only the "Coven" trigger is recognized. Based on your answer though, I'm assuming regex would be the best way to handle that one as well. Heh. I just started using MXP, and now I get to study up on regex. Unless you can think of an easier way. I'm guessing #TRIGGER {"Coven"} won't work, either. :P Thanks for the help, and any more advice you can provide.
Charneus |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jul 29, 2007 7:17 pm |
Well, you could put spaces before or after the Coven part unless spaces don't appear. If it's surrounded by brackets or something, it wouldn't be too hard to add a bracket at the end of your #sub and just have the bracket right there in the pattern.
And really, you can put off learning the whole regex syntax (it's not that hard once you start trying to use it) because \b's the only bit you're going to need in these simple triggers. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Jul 29, 2007 8:25 pm |
If you would prefer not to use regex, use %q. It's identical to \b.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jul 29, 2007 8:35 pm |
I didn't think they were since the helpfile says that %q matches punctuation, which isn't quite true. I stand corrected.
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Jul 30, 2007 12:17 am |
Well, yeah. Anything Zugg does in Zscript is basically Regex plus stuff he thought should be included. So at minimum if all \b does is match one-word tokens on whitespace boundaries, %q would do at least that much and apparently also handles punctuation boundaries (something I thought \b did too).
Also, %q and %y match on the anchor points so that might be another thing that \b doesn't do. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Tue Jul 31, 2007 7:32 pm |
Well, the \b works great, though now that I know about using %q (I'm with Fang on this one, thought it was only punctuation), I'll keep that in mind for the future. Works great now. Thanks for all the help, guys. :)
Charneus |
|
|
|
|
|