Regular Expression find and replace?

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Using the Find and Replace in VS.NET, I'm trying to find methods that are in
the form ....

Foo*[a-zA-Z]*[a-zA-Z][(][)]

and I want to replace them with:

BarFoo*[a-zA-Z]*[a-zA-Z][(][)]

However, put the text above in the Find and Replace respectively replaces
EVERY method FooA(), FooB(), etc with BarFoo*[a-zA-Z]*[a-zA-Z][(][)], rather
than BarFooA() and BarFooB().

Is there a nice way to do this? I can't just look for the word Foo ... it's
everywhere. Wild cards appear to have similar behavior.

Thanks in advance.

Mark
 
Using the Find and Replace in VS.NET, I'm trying to find methods that are
in
the form ....

Foo*[a-zA-Z]*[a-zA-Z][(][)]

and I want to replace them with:

BarFoo*[a-zA-Z]*[a-zA-Z][(][)]

However, put the text above in the Find and Replace respectively replaces
EVERY method FooA(), FooB(), etc with BarFoo*[a-zA-Z]*[a-zA-Z][(][)], rather
than BarFooA() and BarFooB().

Is there a nice way to do this? I can't just look for the word Foo ... it's
everywhere. Wild cards appear to have similar behavior.

You need to tag expressions using {} in your search stirng and then use the
value of the tagged expressions (\1 for the first tagged expression, \2
for the second tagged expression etc.) in the replace string.
eg.

in Find , use Foo{[a-zA-Z]}{[a-zA-Z]}{[(]}{[)]}

and in Replace use : BarFoo\1\2\3\4


--
Adrian Mascarenhas, Developer Division

This posting is provided "AS IS" with no warranties, and confers no rights.

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 
Back
Top