js正則運算式在指定位置插入資料代碼
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "HTTP://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="HTTP://www.jzread.com/1999/xhtml">
<head>
<meta HTTP-equiv=" Content-Type" content="text/html; charset=gb2312" />
<title>js正則運算式在指定位置插入資料代碼</title>
</head>
<body>
<script type="text/javascript教程">
//<![ CDATA[
var g='<b><span class="aaa" style="....."></span></b> --> <b><span class="aaa" style=".....">123</span></b>';
function fillInner(html,val){
return html.toString().replace(/(<(D+)[^>]*>)([^ <]*)(</2>)/g,'$1'+val+'$4')
};
alert(fillInner(g,'google'));
//]] >
</script><script type="text/javascript">
//<![ CDATA[
var g='<b><span></span></b> --> <b><span>123</span></b >';
function fillInner(html,val){
return html.toString().replace(/(<(D+)>)([^<]*)( </2>)/g,'$1'+val+'$4')
};
alert(fillInner(g,'google'));
//]] >
</script>
</body>
</html>