I have to find all the strings surrounded by "[" and "]" using regex, but avoiding the ones inside the <table></table> block, for example:
<html>
<body>
<p><table>
   <tbody>
      <tr>
         <td style="border-style: solid; border-width:1px;">
            <span style="font-family: Courier;">[data1]</span>
         </td>
         <td style="border-style: solid; border-width:1px;">
            <span style="font-family: Courier;">[data10]</span>
         </td>
      </tr>
   </tbody>
</table>
</p>
<p>[data3]  [data4]  [data5]</p>
</body>
</html>
in this case only [data3], [data4] and [data5] should be found.
So far I have this:
 @"(((?<!<span>)(\[[a-zA-Z_0-9]+)](?!<\/span>))|((?<!<span>)(\[[a-zA-Z_0-9]+)])|((\[[a-zA-Z_0-9]+)](?!<\/span>)))(?!.*\1)"
That finds all the [] blocks that are not surrounded by  tags and I tried adding a negative lookahead and lookbehind of  but it doesn't work, it stills gets the ones inside the table block.
Hope you guys can help me with this.
 
     
    