AI销管
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 jaren geleden
123456789101112131415
  1. function trim(str, pos = 'both') {
  2. if (pos == 'both') {
  3. return str.replace(/^\s+|\s+$/g, "");
  4. } else if (pos == "left") {
  5. return str.replace(/^\s*/, '');
  6. } else if (pos == 'right') {
  7. return str.replace(/(\s*$)/g, "");
  8. } else if (pos == 'all') {
  9. return str.replace(/\s+/g, "");
  10. } else {
  11. return str;
  12. }
  13. }
  14. export default trim