Regular Expression find and replace?

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
 
A

Adrian Mascarenhas

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top