search refactoring and regexp validating