[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Highlighting when brackets involved?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Highlighting when brackets involved?

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Hurriedcorgi   USA  (6 posts)  [Biography] bio
Date Tue 22 Nov 2011 07:47 AM (UTC)  quote  ]

Amended on Tue 22 Nov 2011 07:48 AM (UTC) by Hurriedcorgi

Message
Here is the trigger:

<triggers>
<trigger
custom_colour="17"
enabled="y"
group="Highlighted Words"
ignore_case="y"
keep_evaluating="y"
match="\b\[Cockatrice\]\b"
regexp="y"
repeat="y"
sequence="90"
other_text_colour="yellow"
>
</trigger>
</triggers>

The output (and problem):
[Cockatrice] Rusul says,

If I try to get it to just highlight Cockatrice without the brackets in the trigger - it will highlight every instance of the word. I want it to highlight the Cockatrice com channel only; thus, I need it to detect and highlight those brackets too. I've tried everything I can think of - including searching all over the forum and help and just can't get it to work. Thanks in advance for the help!
[Go to top] top

Posted by Twisol   USA  (2,230 posts)  [Biography] bio
Date Reply #1 on Tue 22 Nov 2011 08:29 AM (UTC)  quote  ]

Amended on Tue 22 Nov 2011 08:35 AM (UTC) by Twisol

Message
There are two immediate possibilities. One: use regex lookbehind/lookahead, effectively matching the [ and ] without including them. That would look like \b(?<=\[)Cockatrice(?=\])\b if I'm not mistaken. Possibly the simplest solution here, but it might not work well in more general cases. (Info on lookaround here: http://www.regular-expressions.info/lookaround.html)

A more general solution would be having two triggers. The first matches [Cockatrice], but doesn't do anything to it. Instead, it enables the second trigger, which only matches Cockatrice (and only once on the line), highlights it, then disabling itself.

([EDIT]: Reading your solution below, and re-reading the problem above, I think I misinterpreted the issue. :/ )

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Hurriedcorgi   USA  (6 posts)  [Biography] bio
Date Reply #2 on Tue 22 Nov 2011 08:31 AM (UTC)  quote  ]
Message
Works perfect. Took me forever to figure out but it's this simple.

<triggers>
<trigger
custom_colour="17"
enabled="y"
group="Highlighted Words"
ignore_case="y"
keep_evaluating="y"
match="\[Cockatrice\]"
regexp="y"
repeat="y"
sequence="90"
other_text_colour="cadetblue"
>
</trigger>
</triggers>
[Go to top] 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.


1,361 views.

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]