; $_iswm by Sigh
; Lets you escape characters when performing a wildmatch
; Usage: $_iswm(string,match1,match2,...,matchN)
; Returns $true if any of the matches given is a wildmatch of the string
; Characters are escaped with a backslash character \
; For example, to check if "ab" exists anywhere in $1- you could use if ($_iswm($1-,*a*b))
alias _iswm {
var %i = 2,%m
while (* iswm $($ $+ %i,2)) {
.echo -q $regsub(a,$replacecs($v2,\\,\\E\\134\\Q) ,/(?<!\\)(?:(\*)|\?)/g,\\\\E.\1\\\\Q,%m) $&
$regsub(%m,/(?<=^| )&(?= |$)/g,\\\\E[^ ]+\\\\Q,%m) $regsub(%m,/(?<!\\)\\/g,,%m)
if ($regex($1,$+(/^\Q,%m,\E$/s,$iif($prop != cs,i)))) return $true
inc %i
}
return $false
}