UNPKG

py-uni

Version:

py-uni

16 lines (14 loc) 407 B
function trim(str: any, pos = 'both') { if (pos == 'both') { return str.replace(/^\s+|\s+$/g, ""); } else if (pos == "left") { return str.replace(/^\s*/, ''); } else if (pos == 'right') { return str.replace(/(\s*$)/g, ""); } else if (pos == 'all') { return str.replace(/\s+/g, ""); } else { return str; } } export default trim