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
➜ General
➜ Highlight from variable on multiple values
|
Highlight from variable on multiple values
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Rhien
(13 posts) Bio
|
| Date
| Thu 21 Dec 2017 06:02 PM (UTC) |
| Message
| Having an issue getting highlighting to work with a variable that has multiple values, although if I put the value of that variable directly into the regex it works.
Variable Contents:
<variable name="target">John|Bob|Jim|Freddy</variable>
This trigger does not work:
<trigger
custom_colour="2"
enabled="y"
expand_variables="y"
group="Highlighted Words"
ignore_case="y"
keep_evaluating="y"
match="\b(@target)\b"
regexp="y"
repeat="y"
send_to="12"
sequence="99"
other_text_colour="red"
>
This trigger does work:
<trigger
custom_colour="2"
enabled="y"
expand_variables="y"
group="Highlighted Words"
ignore_case="y"
keep_evaluating="y"
match="\b(John|Bob|Jim|Freddy)\b"
regexp="y"
repeat="y"
send_to="12"
sequence="99"
other_text_colour="red"
>
Now, to prove the variable is making it into the match I changed @target to have a single name and then it works (but it stops working when I put an additional value separated by a pipe in the variable). | | Top |
|
| Posted by
| Rhien
(13 posts) Bio
|
| Date
| Reply #1 on Thu 21 Dec 2017 06:27 PM (UTC) |
| Message
| I think I answered my original question again, although I don't understand why so maybe I'll change that to my question.
I changed "@target" to "@!target" and then it worked with the piped string list. I saw another example where someone used that syntax and thought I'd try (and it worked).
I guess my new question is, What is the difference between "@target" and "@!target"? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Thu 21 Dec 2017 08:03 PM (UTC) |
| Message
| If you use @target the client assumes you might have any text there, and in order to make the regexp "safe" will put backslashes before magic characters, to that "|" will become "\|".
If you use the @!target method this suppresses this action, so that you can use special regexp characters (as you have done) in the variable. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Rhien
(13 posts) Bio
|
| Date
| Reply #3 on Fri 22 Dec 2017 12:30 AM (UTC) |
| Message
| | Got it. Thanks again Nick. | | 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.
14,563 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top