Your absolutely right my post had little to contribute other then a few bytes saved.
on *:input:*: if ($regex($1,/^\*/)) { echo -a You typed a * }
$regex returns the total matches so the if statement will be false if it doesn't find any since 0 is false.
regular expressions are enclosed in a pair of / so the actual expression is ^\*
^
means the start of the string
\*
since * is a special character to quantify a character zero or more times it needs to be escaped so it loses it special meaning and becomes the litural *
so ^\* means if the string ($1- in this case) starts with a * then return true.
Quantifiers:
*: $regex(a,ab*) returns true because a is followed by zero or more b characters.
The other quantifier is +: which means 1 or more
so
$regex(a,ab+) is false because a isn't followed by one or more b's