利用正则式实现首字母大写,丧心病狂是不是?好好的substr不用. JavaScript replace() 方法 r = /^(.)(?=.*)/; str = 'abc'; var str2 = str.replace(r, function (mstr) { return mstr.toUpperCase(); }) console.log(str2) // Abc 来源:https://www.cnblogs.com/wancy86/p/6994432.html 标签 javascript replace