var text ="javascript not java";
function f(word){
return word.substring(0,1).toUpperCase() +word.substring(1);//首字母大写
}
console.log(text.replace(/\b\w+\b/g,f)) //Javascript Not Java
var t="javascript";
//$1,$2, ...,$99 与正则表达式中的第1-99表达式相匹配的文本
//$& 与正则表达式相匹配的字符串
//$`位于匹配子字符串左侧的文本
//$'位于匹配子表达式右侧的文本
var b =t.replace(/(java)(script)/,"$2-$1") //script-java
var c = t.replace(/.*/g,"$&$&"); //javascriptjavascript
var d = t.replace(/script/,"$& != $`"); //javascript != java
var e = t.replace(/java/,"$&$' is "); //javascript is script
var s="<h3>#{title}</h3><div>#{content}</div>"
var f= function(){
var data={title:"liulang",content:"liulang'blog"}
//for(var i=0; i<arguments.length;i++){
//document.write("第"+(i+1)+"个参数的值:"+arguments[i]);
//document.write("<br />");
return data[arguments[2]];
//};
}
var a= s.replace(/(#\{(.*?)\})/g,f);
alert(a);