export class StringUtils { public static trim ( stringToTrim , characterMask ) { const charlist = this . parseCharlist ( characterMask ) ; const re = new RegExp ( '^[' + charlist + ']+|[' + charlist + ']+$' , 'g' ) ; return stringToTrim . replace ( re , '' ) ; } public static ltrim ( stringToTrim , characterMask ) { return stringToTrim . replace ( /^\s+/ , '' ) ; } public static rtrim ( stringToTrim , characterMask ) { const charlist = this . parseCharlist ( characterMask ) ; const re = new RegExp ( '[' + charlist + ']+$' , 'g' ) ; return stringToTrim . replace ( re , '' ) ; } private static parseCharlist ( charlist ) { return ! charlist ? ' \\s\u00A0' : ( charlist + '' ) . replace ( /([[\]().?/*{}+$^:])/g , '\\$1' ) ; } }