mIRC Homepage
Posted By: mmmmm Single Character Highlights - 09/05/14 06:07 PM
Not sure if this should be in here or in the scripts section.


Just wondering if there is there any way to limit highlights for a single character nickname with regex so the highlight only triggers on exact match and exact match followed by a symbol?

Currently using $me with match on message (matching nick/both triggers the highlight when someone with symbols in their nick speaks)

for example:

Z (wanted)
Z: (wanted)

:Z (unwanted)


Preferably using the built in highlighting rather than a standalone script, I don't mind it as it is but it would be nice to remove the 'false' highlights if possible.

Cheers
Posted By: Wims Re: Single Character Highlights - 10/05/14 07:26 PM
mIRC currently lacks the possibility to use $identifier with parameters inside the highlight's entry.
You can use $me but $me might very well contain meaningful characters used in regex, which would need to be escaped, this is usually done with a simple $replacecs(), but like I just said you cannot use $replacecs() here so there are no way to use $me correctly with a regex match.
That said, it's quite ok to assume that $me won't contain anything meaningful in regex and according to your three examples, you could try to use /(?:^| ) $+ $me $+ (?:$|[ :])/
Posted By: mmmmm Re: Single Character Highlights - 11/05/14 04:34 PM
Originally Posted By: Wims
mIRC currently lacks the possibility to use $identifier with parameters inside the highlight's entry.
You can use $me but $me might very well contain meaningful characters used in regex, which would need to be escaped, this is usually done with a simple $replacecs(), but like I just said you cannot use $replacecs() here so there are no way to use $me correctly with a regex match.
That said, it's quite ok to assume that $me won't contain anything meaningful in regex and according to your three examples, you could try to use /(?:^| ) $+ $me $+ (?:$|[ :])/


Unfortunately I couldn't get anything to trigger a highlight when using this
Posted By: Wims Re: Single Character Highlights - 11/05/14 04:35 PM
What was the value of $me when you tried?
Posted By: mmmmm Re: Single Character Highlights - 11/05/14 04:42 PM
Originally Posted By: Wims
What was the value of $me when you tried?


M
Posted By: Wims Re: Single Character Highlights - 11/05/14 05:23 PM
And what was the line sent to test this?

Bah, mIRC needs a way to know it must evaluate the entry, use $(/(?:^| ) $+ $me $+ (?:$|[ :])/)
Posted By: mmmmm Re: Single Character Highlights - 12/05/14 06:34 PM
Originally Posted By: Wims
And what was the line sent to test this?

Bah, mIRC needs a way to know it must evaluate the entry, use $(/(?:^| ) $+ $me $+ (?:$|[ :])/)


As far as I can tell that's working great, is it possible to allow symbols such as ?!,. to trigger the highlight instead of just :

Thanks
Posted By: Wims Re: Single Character Highlights - 12/05/14 07:41 PM
Yes, you can add anything between \Q and \E:
$(/(?:^| ) $+ $me $+ (?:$|[\Q :?!\E])/)
Though, like I said, you might quickly end up wanting the behavior of \b, which handles exactly that kind of situation.
Posted By: mmmmm Re: Single Character Highlights - 14/05/14 03:23 AM
Originally Posted By: Wims
Yes, you can add anything between \Q and \E:
$(/(?:^| ) $+ $me $+ (?:$|[\Q :?!\E])/)
Though, like I said, you might quickly end up wanting the behavior of \b, which handles exactly that kind of situation.


This also works great, until a comma is used, which results in no highlights working
Posted By: Wims Re: Single Character Highlights - 14/05/14 11:38 AM
Right, you might be familiar with the identifier syntax, where the comma is the character used to seperate arguments:

$identifier(<arg1>,<arg2>,<argN>)

You cannot use a litteral comma as part of an argument, you must escape it for mIRC to see it as part of the argument.
One way to achieve that is to use $chr(44):

$(/(?:^| ) $+ $me $+ (?:$|[\Q $chr(44) $+ :?!\E])/)
Posted By: mmmmm Re: Single Character Highlights - 15/05/14 03:12 PM
Originally Posted By: Wims
Right, you might be familiar with the identifier syntax, where the comma is the character used to seperate arguments:

$identifier(<arg1>,<arg2>,<argN>)

You cannot use a litteral comma as part of an argument, you must escape it for mIRC to see it as part of the argument.
One way to achieve that is to use $chr(44):

$(/(?:^| ) $+ $me $+ (?:$|[\Q $chr(44) $+ :?!\E])/)


That's excellent, thanks a lot for the constant help smile
© mIRC Discussion Forums