Minor refactoring to Regular Expression Matching