(bind-func regex_replace_all
(lambda (regex:i8* str:i8* replace:i8*)
(let ((res:i8* (salloc 4096))
(tmp:String* (Str str))
(cnt 0))
(while (and (regex_match regex tmp)
(< cnt 100))
(set! tmp (regex_replace regex tmp replace))
(set! cnt (+ cnt 1)))
tmp)))