Reputation: 2919
We have a requirement to replace word 'ABC'(dummied) with 'XYZ'(dummied) in all the files. We have hundreds of aspx/ascx/cs/xml/xsl files which might contain the word.
The requirement is
This will be 1 time activity. How do I parse entire file for the given word and replace it if condition is satisfied? Planning to use Regex.
Any other ideas is really appreciated. Does a tool already exists that does this? I have tried to google but could not find such a tool.
Upvotes: 0
Views: 284
Reputation: 13327
Tools like PowerGREP are always helpful. Together with RegexBuddy you have a powerful toolset which helps to learn regular expressions and master every regex challenge.
Upvotes: 2
Reputation: 10813
If this is truly a one-time activity, I'd vote for simply using Visual Studio Search/Replace, even if it's a bunch of solutions. Why reinvent the wheel, especially since, realistically, you are much more likely to not do it correctly the first time, and have to undo hundreds of changes manually?
If you use source control (you do use source control, right?), I would highly recommend doing a diff on the files before you check them in, no matter what solution you use.
Upvotes: 2
Reputation: 273274
Investigate if you can translate you requirements into regular expressions. Probably one filetype at a time.
Then, don' write a program but use an existing tool (SED).
But some of your rules seem very complex.
Upvotes: 1