去除字符串中的空格
2020-03-29 本文已影响0人
大胡子111
案例1:首尾,中间空格去除
let str1 = ' 3 4 5 90 uuuu '
str1.replace(/\s/g, "") // 正则匹配
案例2:去除首尾空格
let str2=' 89 '
str2.trim()
案例1:首尾,中间空格去除
let str1 = ' 3 4 5 90 uuuu '
str1.replace(/\s/g, "") // 正则匹配
案例2:去除首尾空格
let str2=' 89 '
str2.trim()