By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,313 Members | 1,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,313 IT Pros & Developers. It's quick & easy.

Regular Expression find and replace?

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
>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][(][)], ratherthan BarFooA() and BarFooB().

Is there a nice way to do this? I can't just look for the word Foo ... it'severywhere. 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.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.