tags:

views:

73

answers:

2

Hi All,

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

  1. Do not replace word if it is part of NameSpace(eg ABC.A1.A2 should not be replaced) or variable names(var abc = "") or tags (abc:control).
  2. The word should be replaced only if it is a whole word( In my cs file, if I have a variable name same as the word i am looking for, it should not be replaced . If I have a string literal eg var str = " ABC is good product". It should be replaced in this case

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.

+1  A: 

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.

splash
+2  A: 

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.

Wonko the Sane
good point Wonko. I cannot use the VS search replace feature because the aspx files are not part of solution. But may be a doable thing
Yogendra
You can still open the aspx files in VS (just drop 'em on the open IDE), and search/replace in All Open Documents.
Wonko the Sane
@Wonko, I see what you are saying. That might be a workable soln. :)
Yogendra