I am asking for help to test and break this script. Otherwise, I'm featuring it here so people can start using it far and wide.
I'd like to know if it works in v6.35 pre-UTF8 support.
- Raccoon

Code:
; $is_nickspam() - Nickname Highlight Spam Detector by Raccoon 2017.
; Parameters: $is_nickspam(<channel>,<text>,[M=5],[N=8])  eg: $is_nickspam($chan,$1-,5,8)  or just  $is_nickspam($chan,$1-)
;   Where M (>=2) is minimum nickname length to regard, and N (>=1) is number of matches considered as spammy.  Defaults: M = 5, N = 8.
; Returns: Number of positive nickname matches in the string, if it exceeds [N].  Returns 0 if less than [N]. 
; Note: This script looks at nickname parts that contain Letters, Numbers and Underscores, to detect variously decorated spam.
; Example Usage:  (Un-comment the next 5 lines to activate, and enjoy.)
; On @*:TEXT:????????????????????????????????????????????????????????????*:#: {
;   if ($nick !isop $chan) && (!$($+(%,_spamban.,$cid,$chan,$nick),2)) && ($is_nickspam($chan,$1-)) {
;     ban -k $chan $nick 2 Lame Highlight Spam Detected.
;     inc -z $+(%,_spamban.,$cid,$chan,$nick) 5
; } }
ALIAS is_nickspam { 
  var %chan = $$1, %text = $$2, %nicklen = $$iif($calc($3 -1) > 0,$v1,4), %nickspam = $$iif($calc($4) > 0,$v1,8)
  var %text = $mid($regsubex(is_nickspam,! %text !,/(*UTF8)(?:\W++|(?<!\w)(?:\w{1, $+ %nicklen $+ }|(\w++)(?=.*?\W\1(?:\W|$)))(?!\w))+/gx,|),2,-1)
  if (%chan ischan) && ($numtok(%text,124) >= %nickspam) && ($fline(%chan,/(?<=^|\W)(?: $+ %text $+ )(?=\W|$)/i,0,3) >= %nickspam) { return $v1 }
  return 0
} ; by Raccoon 2017 Feb 28 - http://www.mpaste.com/p/Tu7NJh - http://hawkee.com/snippet/18055/


Well. At least I won lunch.
Good philosophy, see good in bad, I like!