Clean up un-escaped '$' in regex
Fix input trimming to not strip spaces