src/lib/utils/Str.js
function trimHandle(str, chars = ' ', position) {

    if (typeof str !== 'string') {
        return;
    }

    let cs = chars;

    if (Valid.isArray(chars)) {
        cs = chars.join('');
    }

    const startReg = new RegExp(`^[${cs}]*`, 'g'),
        endReg = new RegExp(`[${cs}]*$`, 'g');

    if (position === 'start') {
        return str.replace(startReg, '');
    } else if (position === 'end') {
        return str.replace(endReg, '');
    }

    return str.replace(startReg, '').replace(endReg, '');

}
function trimHandle(str, chars = ' ', position) {

    if (typeof str !== 'string') {
        return;
    }

    let cs = chars;

    if (Valid.isArray(chars)) {
        cs = chars.join('');
    }

    const startReg = new RegExp(`^[${cs}]*`, 'g'),
        endReg = new RegExp(`[${cs}]*$`, 'g');

    if (position === 'start') {
        return str.replace(startReg, '');
    } else if (position === 'end') {
        return str.replace(endReg, '');
    }

    return str.replace(startReg, '').replace(endReg, '');

}
function trimHandle ( str , chars = ' ' , position ) { if ( typeof str !== 'string' ) { return ; } let cs = chars ; if ( Valid . isArray ( chars ) ) { cs = chars . join ( '' ) ; } const startReg = new RegExp ( ` ${ cs } ` , 'g' ) , endReg = new RegExp ( ` ${ cs } ` , 'g' ) ; if ( position === 'start' ) { return str . replace ( startReg , '' ) ; } else if ( position === 'end' ) { return str . replace ( endReg , '' ) ; } return str . replace ( startReg , '' ) . replace ( endReg , '' ) ; }
string trim handle method
@param str
@param chars
@param position
string trim handle method