Visual Studio 中的正则表达式搜索
我正在使用的代码有大量我想要删除的样式。以下是代码片段
asp:Label ID="LabelMeterNo" runat="server" Font-Names="Tahoma"
Style="z-index: 126; left: 72px; top: 203px" Text="MeterNo"
Width="136px"></asp:Label>
以前的程序员对页面上的每个控件都使用了 z 索引和位置。实在是太多了,无法一一查找。是否有一个正则表达式可以捕捉到这个
Style="z-index: 126; left: 72px; top: 203px"
Style="z-index: 124; left: 216px;
top: 261px"
Style="z-index: 124; left: 216px;
top: 291px"
肯定有更多的组合。请注意上面示例 2 和 3 中的换行符。
我想要的是搜索
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. 有没有办法做到这一点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我绝不是正则表达式专家,因此这可能可以稍微清理/修复,但由于我今天刚刚发现 Visual Studio 有趣的正则表达式语法,我想我应该尝试一下。这对我来说适用于 Visual Studio 中的测试数据:
Style\=\"[Zz]-index\:[a-zA-Z0-9; \::Cc]+\"
注意一些字符会像 =、"、: 一样被转义,并且我还使用 :Cc 来匹配换行符。您可能还需要执行一些操作来忽略单词 Style 的大小写。
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.