refactor trim regex evaluation