Modified trim function to support removal via regular expression char group along with leading/trailing spaces