The code that I am working with has tons of style that I want to remove. Here is the code snippet
asp:Label ID="LabelMeterNo" runat="server" Font-Names="Tahoma"
Style="z-index: 126; left: 72px; top: 203px" Text="MeterNo"
Width="136px"></asp:Label>
The previous programmer used the z-index and position for every single control on the page. There are too many to search and find them one by one. Is there a regular expression that will catch this
Style="z-index: 126; left: 72px; top: 203px"
Style="z-index: 124; left: 216px;
top: 261px"
Style="z-index: 124; left: 216px;
top: 291px"
There are certainly more combination of this. Notice the new line character in 2 and 3 example above.
What I would want is search for
Style="Z-index:126; left:72px; right;200px; top:23px; position:relative"
That is start from Style=”Z-index and end at the quotation mark. Is there a way to do it?
I’m by no means a regex expert so this can probably be cleaned/fixed a bit but since I just found out today about Visual Studio’s interesting regex syntax I thought I’d give this a shot. This works for me with your test data in Visual Studio:
Style\=\"[Zz]-index\:[a-zA-Z0-9; \::Cc]+\"Note some characters are escaped like =, “, : and I also use :Cc to match the newline. You may want to do something to ignore the case for the word Style as well.