Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / September 2005

Tip: Looking for answers? Try searching our database.

using a regular expression replace string in VS 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hua-Ying Ling - 30 Sep 2005 19:08 GMT
Hi,

According to the documentation, in the "find & replace" dialog I should be
able to use a regular expression as a replacement string if the "Use:"
checkbox is enabled and "Regular Expressions" is selected.

I'm trying to do the following:

replace the first string with the second string:
mName kName
mValue kValue
mDescription kDescription

I'm using the following regular expressions in the find and replace fields:
find what: "^m.+"
replace with: "^k.+"

Did I miss something?
Thanks
Hua-Ying
Paul Colton - 30 Sep 2005 20:08 GMT
Hua-Ying,

You have to surround the match expression you want to use in your search
string with curly braces (called a "Tag expression"). Then these tag
expressions are referenced in the replace expression by index.  "\1" is the
first tag expression, "\2" is the second, and so on.

For example:

find: {.+} eats {.+}
replace: \2 is eaten by \1

       cat eats mouse
   ...becomes...
       mouse is eaten by cat

so, for your example

find: ^m{.+}
replace: k\1

Note that you don't need the "^" character (match beginning of line) in the
replace expression

Hope that helps.

-Scott

> Hi,
>
[quoted text clipped - 17 lines]
> Thanks
> Hua-Ying

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.