add support for multiple patterns
fix remove newline/space, add leading/trailing space handling