consolidated trims and regex compares

allowed them to be accessed externally for testing purposes