need help on regex

  • Thread starter Thread starter Guest
  • Start date Start date
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...
 
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
 
<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\\")
 
Back
Top