javascript--正则
- 字符串去除空格
去除所有空格
var txt=document.getElementById('txt').value; txt=txt.replace(/\s+/g,"");
去除两头空格
var txt=document.getElementById('txt').value; txt=txt.replace(/^\s+|\s+$/g,"");
去除左边空格
var txt=document.getElementById('txt').value; txt=txt.replace(/^\s*/g,"");
去除右边空格
var txt=document.getElementById('txt').value; txt=txt.replace(/(\s*$)/g,"");
获取注释中的一行
function hereDoc(f) {return f.toString().replace(/^[^\/]+\/\*!?\s?/, '').replace(/\*\/[^\/]+$/, '');}

浙公网安备 33010602011771号