如何使用 VS 或其他文本编辑器搜索和替换文件中的大块文本?
我有一堆旧的 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.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