如何使用 VS 或其他文本编辑器搜索和替换文件中的大块文本?

发布于 2024-09-24 14:20:46 字数 292 浏览 1 评论 0原文

我有一堆旧的 .asp 文件需要重构,我要做的第一件事就是用服务器替换每个文件(它是一个菜单)中重复的庞大 侧面包括。

该表没有 id,但它的容器有它:

 <td id="leftColumn" >
               <table>

手动浏览文件并替换表是不可行的,而且很无聊...... 你会怎么做?我有 VS2010、Notepad++,但我愿意接受每一个建议。

提前致谢。

I have a bunch of old .asp files to refactor, and the first thing I have to do is to replace a bulky <table> wich is repeated in every file (it's a menu) with a server side include.

the table has no id, but its container has it:

 <td id="leftColumn" >
               <table>

manually going through the files and replacing the table is unfeasible, AND boring...
How would you do this? I have VS2010, Notepad++, but I am open to every advice.

thanks in advance.

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

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

发布评论

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

评论(1

海夕 2024-10-01 14:20:46

.asp 文件可能不是格式良好的 XML,因此 XSL(我的第一个想法)不起作用。我会尝试编写一个与表格外部匹配的正则表达式,并将其替换为其他内容。通常不赞成使用正则表达式来解析 xml,但在这种情况下,我认为您不会拥有格式良好的 xml,所以我认为这是可以的。

请参阅 Scott Hanselman 在“正则表达式”下的工具列表,了解合适的编辑器,您可以在其中针对需要重构的源文件测试您的表达式。
http://www.hanselman.com/blog/ScottHanselmans2009UltimateDeveloperAndPowerUsersToolListForWindows.aspx

The .asp files are probably not well-formed XML, so XSL (my first thought) wouldn't work. I'd try to write a regex that matches the outside of your table and replaces it with other content. Regex is generlly frowned upon to parse xml, but in this case, I don't think you will have wellformed xml, so I think it's ok.

See Scott Hanselman's tools list under 'Regular Expressions' for a suitable editor in which you can test your esxpressions against the source files you need to refactor.
http://www.hanselman.com/blog/ScottHanselmans2009UltimateDeveloperAndPowerUsersToolListForWindows.aspx

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