Meanwhile, you can use this simple alias:
alias regtok {
!.echo -q $regex(rgt,$1,/(?(?! $+ $3 $+ )(.+?))(?: $+ $3 $+ |$)/g)
if $2 < 0 { return $regml(rgt,$iif($calc($regml(rgt,0) + 1 + $2) > 0,$ifmatch)) }
return $regml(rgt,$2)
}
It doesn't support token ranges (eg $regtok(<input>,1-3,<regex>) ) but it supports negative tokens. It's very possible to make it support ranges (by using the
.pos property in $regml()) but it gets kinda slower and I won't attempt to make it unless you need it.