tags:

views:

115

answers:

3

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?

+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
A: 

Rather than a regex I'd suggest using the String.Replace("&","&") string function.

Lazarus
A: 

Why don't you do just:

string.Join("\n", System.IO.File.ReadAllLines("file.txt")).Replace("&", "&");

?

eKek0