<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/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+)[^>]*>)([^<]*)(</>)/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+)>)([^<]*)(</>)/g,'$1'+val+'$4')
};
alert(fillInner(g,'google'));
//]]>
</script>
</body>
</html>