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 / August 2006

Tip: Looking for answers? Try searching our database.

Find and Replace using regular expressions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
richie_hackett@hotmail.com - 23 Aug 2006 16:59 GMT
The problem
I need to go through each html page in a folder/sub folder and alter
the src attribute to a flat directory structure and prefixed with an
absolute path

To do this I was going to write a simple app but decided instead to try
and use the find and replace in files options in VS 2003.

My issue is that my regex really sucks.

What I need to do is take
<img src="./a/test/img.jpg">
<img src='a/test/img.gif'>
<img src='a/deep/test/img.jpg'>
type url's and replace with
<img src="http://myserver/images/img.jpg">
<img src="http://myserver/images/img.gif">
etc

Any ideas how I could do this?
Mike Blake-Knox - 25 Aug 2006 18:25 GMT
> What I need to do is take
> <img src="./a/test/img.jpg">
[quoted text clipped - 4 lines]
> <img src="http://myserver/images/img.gif">
> etc

Try something like <img src="./a/test/{[a-zA-Z0-9]+}\.{(jpg)|(gif)}" in
Find what and <img src="http://myserver/images/\1.\2" in the Replace
with field of the VS Replace dialog.

You could use ["'] instead of " in the Find text if you really have a
mixture of single and double quotes.

Mike

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.