frege-repl-3 Refactor regex matching