js str字符串的常用方法

将字符串按照逗号分割

  • 将字符串按照逗号分割
  • 删除指定字符串

将字符串按照逗号分割

var str = "a,b,c";
var m = str.split(","); //['a', 'b', 'c']

删除指定字符串

let url = "http://test123456.top/avatar/123456789png";
let newUrl = url.replace("http://test123456.top/", "");//avatar/123456789png

你可能感兴趣的:(JavaScript,javascript,前端,html)