Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Tips and tricks
➜ RegExp puzzle
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Neurowiz
(17 posts) Bio
|
Date
| Fri 03 Jan 2003 05:26 AM (UTC) |
Message
| I'm inexperienced with regex, but I'm not quite certain how to pull this off:
There is a message that I might be afflicted with paralysis. Unfortunately, the way the game does it is to replace various letters with asterisks at random characters:
"A prickly stinging overcomes your body, fading away into numbness."
It will show up like so:
A *rick*y stin*ing *ver*comes ...
Anyway you get the idea.
Now originally, I set up a regex to look like so:
^(A|\*)( |\*)(p|\*)(r|\*)(i|\*)(c|\*)(k|\*)(l|\*)(y|\*).*$
Now this does work.. but with some unintended side effects... if I see a line of all asterisks, then the regex is interpreted to be true. I can't figure out how to make it work so that it would pick up when I have random characters in a line substituted by asterisks, and yet not a solid line of asterisks.
Any hints to get me in the right direction?
Thanks!
Regards,
Neurowiz | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #1 on Fri 03 Jan 2003 06:22 AM (UTC) |
Message
| Hey, Neuro
This has already come up on this board before, so I'll just post the results of the previous discussion that I use now.
The trigger looks like:
^((?:A|\*)(?: |\*)(?:p|\*)(?:r|\*)(?:i|\*)(?:c|\*)(?:k|\*)(?:l|\*)(?:y|\*)(?: |\*)(?:s|\*)(?:t|\*)(?:i|\*)(?:n|\*)(?:g|\*)(?:i|\*)(?:n|\*)(?:g|\*)(?: |\*)(?:o|\*)(?:v|\*)(?:e|\*)(?:r|\*)(?:c|\*)(?:o|\*)(?:m|\*)(?:e|\*)(?:s|\*)(?: |\*)(?:y|\*)(?:o|\*)(?:u|\*)(?:r|\*)(?: |\*)(?:b|\*)(?:o|\*)(?:d|\*)(?:y|\*)(?:\,|\*)(?: |\*)(?:f|\*)(?:a|\*)(?:d|\*)(?:i|\*)(?:n|\*)(?:g|\*)(?: |\*)(?:a|\*)(?:w|\*)(?:a|\*)(?:y|\*)(?: |\*)(?:i|\*)(?:n|\*)(?:t|\*)(?:o|\*)(?: |\*)(?:n|\*)(?:u|\*)(?:m|\*)(?:b|\*)(?:n|\*)(?:e|\*)(?:s|\*)(?:s|\*)(?:\.|\*))$
This does match on an all-asterix line, but it must have a specific number of asterix in it. Basically, any char in the matched line can be either a certain letter, a space, a punctuation sign or an asterix. I am sure you get the idea.
'?' mean either-or.
There's actually another form of the same line, which has a * after the period and no newline, meaning that the prompt from the following line gets dragged into the end of the matched one. The trigger above can't handle that, so I used a non-regexp trigger to handle it. Obviously, it presumes that there's just one literal form of the message. I am not sure if that is the case, but I am using it for now. Here it is:
A prickly stingin* overwhelms your body, fading away *nto numbness*
Hope that helps.
| Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #2 on Fri 03 Jan 2003 06:28 AM (UTC) |
Message
| Correction,
'|' mean either-or; '?' prevent you from getting a too-many-wildcards error, which you would otherwise get with that many parentheses in there. | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #3 on Fri 03 Jan 2003 05:43 PM (UTC) |
Message
| Actually, it's the ?: together that indicate the pattern should be searched for, but NOT returned as a wildcard. I'm sure you know that Ked, since you use it in your example. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #4 on Sun 05 Jan 2003 04:02 PM (UTC) |
Message
| Thank you, Magnum. ? on its own certainly means something different - I need to start using RegExp more often, maybe then I won't have a dozen aliases for every little bit of code in my script file :) | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
17,597 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top