一:字符串的分割 str.split('');
let str = "abcd";
let res1 = str.split('');//[ 'a', 'b', 'c', 'd' ]
let res2 = str.split('c');//[ 'ab', 'd' ]
二:字符串的截取 substring、substr、slice
1.str.slice(start,end);//end位置不会截取
let str = "abcdef";
let res1 = str.slice(2,4);//cd
let res2 = str.slice(3);//def
2.str.substring(start,end);//开始位置,结束位置
let str = "abcdef";
let res1 = str.substring(2,3);//c
let res2 = str.substring(3);//def
3.str.substr(start,count);//开始位置,截取数量
let str = "abcdef";
let res1 = str.substr(2,3);//cde
let res2 = str.substr(2);//cdef
三:字符串的替换 str.splace('a','b');//a可以使用正则表达式
let str = "ab_夏夜_cdefa";
let res1 = str.replace('c','哈哈');//ab_夏夜_哈哈defa
let res2 = str.replace(/([\u4E00-\u9FA5])+/g,'xiaye');//ab_xiaye_cdefa
四:字符串大小写转换 toUpper
let str1 = "abc";
let str2 = "EDF";
let res1 = str1.toUpperCase();//ABC
let res2 = str2.toLowerCase();//edf
五:字符串去前后空格
let str = " abc edf ";
let res = str.trim();//abc edf
六:其它
1.字符串的拼接
let str = 'abc' + 'edf';
let str1 = `abc${str}`;//abcabcedf
2.字符串匹配 str.match(str | regexp);//可以是字符串,也是是正则,字符置灰匹配一个,而正则如果/g可以全局匹配
let str = 'abcdheheefj';
let res1 = str.match('he');//['he']
let res2 = str.match(/he/g);//['he','he']