字符串取整数

          e = typeof e === 'string' ? e : e.toString();
          const pattern = /(-?\d+)(\d{3})/;
          while (pattern.test(e)) {
            e = e.replace(pattern, '$1,$2');
          }

123.12 => 123
123#123 => 123

posted @ 2024-04-15 16:32  东八区  阅读(13)  评论(0)    收藏  举报