Visual Studio 中的正则表达式搜索

发布于 2024-12-19 19:17:23 字数 855 浏览 3 评论 0原文

我正在使用的代码有大量我想要删除的样式。以下是代码片段

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?

Here is a page that can be used for reference

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿看小鸭子会跑 2024-12-26 19:17:23

我绝不是正则表达式专家,因此这可能可以稍微清理/修复,但由于我今天刚刚发现 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文