正则替换字符串功能时间:2022-03-01 14:53:34 <a href="1.htm">251</a> 怎么用JS把251替换为 <span style='background-color: #99FF99'>251</span> <script type="text/javascript"> var str='<a href="1.htm">231</a>'; alert(str.replace(/<a([\s\S]*)>([\s\S]*)<\/a>/ig,"<a$1><span style='background-color: #99FF99'>$2</span></a>")); </script>