2014-10-31 14 views
0

這應該使用Visual Studio,正則表達式查找和替換完成。查找存在「display:none」的所有標籤,並添加屬性aria-hidden =「true」

例如:

<tr id="ID1" style="display: none;"></tr> 

替換

<tr id="ID1" style="display: none;" aria-hidden="true"></tr> 

或者

<span id="ID2" class="someClass" style="color:red; display: none;"></span> 

與替換

<span id="ID2" class=" someClass" style="color:red; display: none;" aria-hidden="true"></span> 

我正則表達式來找到所有的顯示標籤:無:

(<[^>]+)display: none; 

,但我不現在如何,以便在此標籤上的新特性? 它應該適用於每個標籤,無論標籤有多少個屬性。

+1

我會更好地使用XML DOM功能來編輯HTML。 – 2014-10-31 07:47:36

+1

使用此。 http://stackoverflow.com/questions/2694640/find-an-element-in-dom-based-on-an-attribute-value – 2014-10-31 07:53:51

回答

1

還是爲了嚴格回答你的問題:

取代:

(<[^>]+)display: none;[^"]*" 

有:

$& aria-hidden="true" 
+0

謝謝。你知道一些很好的書籍/頁面,我可以在哪裏學習這樣的東西? – Raskolnikov 2014-10-31 08:25:33

相關問題