<script>
var str = "<table width=\"100\" height=\"100\" >";
if (!str.match(/<table.+(border).+>/))
  alert("匹配");
</script>

解决方案 »

  1.   

    太简单了吧首先,我只是举的例子我实际的<table>标记有可能是这样
    <table width="1">
    <table width="2">
    ......
    <table width="1000000000000000000000000000">也可能是
    <table width=1>
    ......
    <table width=10000000000000000000000000000>还有可能是
    <table width='1'>
    ......
    <table width='10000000000000000000000000000'>更有可能是
    <table.....width=1......height=1......cellpadding=1 ......cellsapcing=1....>
    可能的情况实在太多了
      

  2.   

    是啊,只要标记中含有border就不会匹配
      

  3.   

    我的目的是这样的我要匹配不存在border的table标记,然后replace()加入border属性如果按你的方法,如何实现这种效果?
      

  4.   

    <script>
    var str = "<table width=\"100\" height=\"100\" >";
    if (!str.match(/<table.+(border).+>/))
        alert(str.replace("<table", "<table border=1"));
    </script>
      

  5.   

    别忘了,Border也可以写在style里。
    甚至,某些人为了做出渐变色的border,不惜用图片来实现
      

  6.   

    Border也可以写在style的话,也可以用js来控制另:还有些意外情况,如border="-1"