日期:2014-05-16  浏览次数:20270 次

一个正则表达的问题,请高手给指点下
我想把 <table   cellspace=     cellpading=   ...   border=   > 中table的样式改成
      <table   cellspace= "0 "   cellpading= "0 "   border= "1 ">
    用正则表达怎么写,,谢谢

------解决方案--------------------
<script language=javascript>
function regexTest(yourStr)
{
return yourStr.replace(/( <table cellspace=)(.*?) (cellpading=)(.*?) (border=)(.*?)(> )/,
"$1\ "0\ "$3\ "0\ "$5\ "1\ "$7 ");
}
alert(regexTest( " <table cellspace= cellpading= ... border= > "));
</script>
------解决方案--------------------
cellspace= cellpading= ... border=

换成 style= "padding:; margin:;border:1px solid red; "
or class= ".table "
or <table id= "tbStyle "> <style> #tbStyle{} </style>