文件
NHCshopro/uniapp/uview-ui/libs/function/trim.js
wikiboss f141d35f1c Add 'uniapp/' from commit '096e31448ca089004c78af69f2006c2b0324d8a4'
git-subtree-dir: uniapp
git-subtree-mainline: b87880e247
git-subtree-split: 096e31448c
2026-11-20 09:08:51 +08:00

16 行
339 B
JavaScript

function trim(str, 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