In an XML file, I am capturing a long list of URLS from a web page, using regex (in .NET). Within the captured URLS, I simply need to substitute '&' for all '&
' that are located within the URLS. How do I do this?
views:
115answers:
3
+1
A:
If you do this and save the results, you'll be left with invalid xml. If you are using a real xml parser the &
will be correctly returned as &
at the time you read it.
If you insist on proceeding, a simple String.Replace("&", "&")
on each url should suffice.
Joel Coehoorn
2009-04-21 14:23:42
A:
Rather than a regex I'd suggest using the String.Replace("&","&")
string function.
Lazarus
2009-04-21 14:23:55
A:
Why don't you do just:
string.Join("\n", System.IO.File.ReadAllLines("file.txt")).Replace("&", "&");
?
eKek0
2009-04-21 14:23:55