refactoring scanner regexp string handling