partial step towards implementing regexec