proto trim with fallback regex

prototype trim with fallback regex