mIRC Homepage
Posted By: Sjoepele Check for asterisk symbols - 25/08/14 12:34 PM
On Twitch.TV, strong language may be filtered and will show up as 3 asterisks (***) in the chat.
for cursing that is not filtered i use 'if (*curseword* iswm $1-)' to check for bad words and purge them from the chat.
Now i wanted to know if i can use something similar to check for 3 asterisks? since 'if (***** iswm $1-)' will obviously not work :P

Help would be highly appreciated smile
Posted By: westor Re: Check for asterisk symbols - 25/08/14 04:28 PM
Try $chr(42) in the if brackets ..
Posted By: Sjoepele Re: Check for asterisk symbols - 25/08/14 05:19 PM
Aw man i was sure that was going to work but it doesnt seem to hmmmm. Oh well, thanks for the input!
Posted By: Wims Re: Check for asterisk symbols - 25/08/14 06:42 PM
What did you use? if ($+(*,$str($chr(42),3),*) iswm $1-) should work
Posted By: Iire Re: Check for asterisk symbols - 25/08/14 08:55 PM
Unfortunately, escaping wildcard characters with their $chr() equivalents won't work, as mIRC will still treat them as wildcards when making a wildmatch comparison. In order to check for them in a string, you'll need to use them in a context where they are not treated as wildcard characters.

In your particular case, since you already appear to be checking if the string occurs anywhere in the line, regardless of what's around it, the isin operator may be a good choice:

Code:
if (*** isin $1-) { ... }


You could also use regex if you want the matching requirements to be highly flexible. (Just keep in mind that you'll need to escape the * and ? characters (in the regex sense) so that they are not treated as meta characters:

Code:
if ($regex($1-,\Q***\E)) { ... }

; or for an example showing more flexibility...
if ($regex($1-,\b\Q***\E\b)) { ... }


There are, of course, also things like $istok() and == for checking whether such chacters are in (or make up) the string; it all depends on your particular need.
Posted By: Wims Re: Check for asterisk symbols - 25/08/14 09:43 PM
Good point, I must have thought it would work because I wanted it to work
Posted By: Sjoepele Re: Check for asterisk symbols - 26/08/14 01:49 AM
Thank you very much for your input guys, i'll be sure to check it tomorrow morning. Highly appreciated smile
Posted By: Sjoepele Re: Check for asterisk symbols - 26/08/14 05:11 PM
yup, worked perfectly! Thanks again smile
© mIRC Discussion Forums