views:

23

answers:

1

Hello, 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.

A: 

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

StephaneT
alas the regular expression syntax that works with .NET is quite different from the one that the find in files feature in Visual Studio uses. Yes, I could write a simple app that enumerates the files, opens them and replaces the text with a Regex that works, but I hoped that I could use (now and in the future) some feauture of my text editors.
pomarc
notepad++ has regex find. http://stackoverflow.com/questions/287404/using-regular-expressions-to-do-mass-replace-in-notepad-and-vim and http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html
StephaneT