src/aria/utils/String.js
function (string, size, character, begin) {
            var start, length;
            if (begin === true) {
                for (start = 0, length = string.length - size; start < length; start += 1) {
                    if (string.charAt(start) !== character) {
                        break;
                    }
                }

                return string.substring(start);
            } else {
                for (start = string.length - 1; start >= size; start -= 1) {
                    if (string.charAt(start) !== character) {
                        break;
                    }
                }

                return string.substring(0, start + 1);
            }
        }
function (string, size, character, begin) {
            var start, length;
            if (begin === true) {
                for (start = 0, length = string.length - size; start < length; start += 1) {
                    if (string.charAt(start) !== character) {
                        break;
                    }
                }

                return string.substring(start);
            } else {
                for (start = string.length - 1; start >= size; start -= 1) {
                    if (string.charAt(start) !== character) {
                        break;
                    }
                }

                return string.substring(0, start + 1);
            }
        }
function ( string , size , character , begin ) { var start , length ; if ( begin === true ) { for ( start = 0 , length = string . length - size ; start < length ; start += 1 ) { if ( string . charAt ( start ) !== character ) { break ; } } return string . substring ( start ) ; } else { for ( start = string . length - 1 ; start >= size ; start -= 1 ) { if ( string . charAt ( start ) !== character ) { break ; } } return string . substring ( 0 , start + 1 ) ; } }
Remove all consecutive occurrences of a character from the beginning or end of a string. It's like trim but
instead of removing white spaces removes the specified character. Unlike trim it works on one direction only.
@param {String} string String to be cropped
@param {Number} size Minimum size of the resulting string
@param {String} character Character to be removed
@param {Boolean} begin Crop from the beginning or the end of the string. If true crops from the beginning.
Default false.
Remove all consecutive occurrences of a character from the beginning or end of a string . It s like trim but instead of removing white spaces removes the specified character . Unlike trim it works on one direction only .