alias re_hfind {
if ($1 == $null) { echo -a Syntax: /re_hfind <matchtext> | return }
;;;;;; Create a table for testing ;;;;;;
if ($hget(test)) hfree test
echo -a Making Table
hmake test 100
var %c = 0, %cc = 3000
while (%c < %cc) {
inc %c
hadd test %c $+($rand(100,999),$chr(9),$rand(100,999),$chr(9),$rand(100,999),$chr(9),$rand(100,999),$chr(9),$rand(100,999),$chr(9),$rand(100,999),$chr(9),$rand(100,999))
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
var %ticks = $ticks
var %matchtext = $re_escape($1)
var %regex = /^(?:\S+\s+){4}( $+ %matchtext $+ )/i
echo -a %regex
var %h, %c = 0, %cc = $hfind(test,%regex,0,r).data
echo 0> $calc($ticks - %ticks) ms
echo -a $hfind(test,*,0,w) items; %cc matches
while (%c < %cc) {
inc %c
%h = $hfind(test,%regex,%c,r).data
echo -a Match: Ticks- $calc($ticks - %ticks) $+ ms Item- %h Data- $hget(test,%h)
}
echo X> $calc($ticks - %ticks) ms
}
alias re_escape return $regsubex($1,/([^\w\s])/g,\\t)