var oBtn = document.getElementById(“btn”);
var oTxt = document.getElementById(“txt”);
oBtn.onclick = function(){
var str = oTxt.value;
//var re = /^\s+/g;
//var re = /\s+KaTeX parse error: Expected group after '^' at position 20: … var re = /(^̲\s+|\s+)/g;
str = str.replace(re,’’);
alert(’-’ + str + ‘-’)
}
相关文章
- 10-27运用正则表达式去左右空格