port regexp lib and tokenizer from narwhal