need help on regex

G

Guest

Hi.
I've a requirement in regular exp..
I need to replace a pattern...can anyone help me out,...

My input string is as below
<img src="c:\windows\images\bluehills.jpg"><a heref="sfjs">
<img src="c:\vij\granny.bmp">.........

My output string should be like
<img src="D:\images\bluehills.jpg"><a heref="sfjs">
<img src="D:\Images\granny.bmp">.........

Can anyone help out in the pattern...
 
B

Bob

Hi,
A match to your first line is
<img src=["]c:\\windows\\images\\bluehills[.]jpg["]><a heref=["]sfjs["]>
Suggest you get a decent regex builder / tester
I use regexbuddy.
You still get some small anomalies sometimes when you feed the expressions
to regex but usually it is so close that you can make the adjustments
easily.
I used to steer well clear of Regex but am now starting to use it. (With a
lot of help from RegexBuddy)
HTH
Bob
 
L

Luc E. Mistiaen

<img src="c:\vij\granny.bmp">.........

My output string should be like
<img src="D:\images\bluehills.jpg"><a heref="sfjs">
<img src="D:\Images\granny.bmp">.........

Regex.Replace (Source, @"c:\\[^\\]+\\", @"D:\\Images\\")
 

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