我想問一下正則表達式問題。我想在vs 2008中搜索以下語法:html標籤attr在vs 2008中的正則表達式
<table width="10%" class="test" style=""> </table>
<table class="test" style="" width="10%"> </table>
<table class="test" width="10%" style=""> </table>
<table class="test" width="10%"></table>
<table class="test"></table>
<table></table>
<div width="10%"></div>
我想在上面的表格文本中搜索所有width =。
搜索正則表達式
table[^\w]+width="[^"]+"
搜索結果
<table width="10%" class="test" style=""> </table>
<table class="test" style="" width="10%"> </table>
<table class="test" width="10%" style=""> </table>
<table class="test" width="10%"></table>
後,我想更換寬度風格= 「WIDTH:」
結果應該是
<table style="width:10%" class="test" style=""> </table>
<table class="test" style="" style="width:10%"> </table>
<table class="test" style="width:10%" style=""> </table>
<table class="test" style="width:10%"></table>
我如何做這個替換?
通常,[正則表達式不是解析HTML的正確工具](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags)。 – Vulcan