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 / General / July 2004

Tip: Looking for answers? Try searching our database.

Search and replace multiple lines

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 24 Jul 2004 04:56 GMT
Hi

I frequently find myself wanting to search for and replace multiple lines -
where I have the same piece of code in several apsx.cs files.

Any guide as to how to do this woudl be appreciated.

David
Peter Macej - 24 Jul 2004 10:27 GMT
It can be done easily using regular expressions in the replace dialog.
Suppose you want to replace each occurence of two lines:
Public Property prop1() As Boolean
    Get

with the following three lines:
Something
Next line
Last line

1. Go to Edit | Find and Replace | Replace in Files
2. In the Use field select Regular expressions instead of Wildcards.
3. Type the following reg. expression in Find what:
Public Property prop1\(\) As Boolean$:Wh*Get
Note, you must escape '(' by '\(', $ stands for EOL, :WH is whitespace,
* means zero or more occurences of previous expression (whitespaces in
our case). You can find a menu ">" with other characters on the right
side of the field.
4. Type in the Replace with:
Something\nNext line\nLast line

Now you can start replace.

Signature

Peter Macej
Helixoft - http://www.vbdocman.com
VBdocman - Automatic generator of technical documentation for VB, VB
.NET and ASP .NET code

David - 24 Jul 2004 18:54 GMT
Hi Peter

That sound ideal. I thought maybe regular expresions - but never really used
them.
About time I did, and now I will!

Many Thanks.

David

> It can be done easily using regular expressions in the replace dialog.
> Suppose you want to replace each occurence of two lines:
[quoted text clipped - 18 lines]
>
> Now you can start replace.

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.