-1

I downloaded some data from a site, and I got this string: Guangzhou R&F, as you can see within the string I have also amp; but the correct string (displayed on the site) is: Guangzhou R&F.

So I'm trying to remove that string using Regex, the expression I wrote is this:

public static string RemoveHtml(string input)
{
    return Regex.Replace(input, @"<[^>]+>|&nbsp;", "").Trim();
}

the problem is that the Regex expression doesn't remove the amp; what I did wrong?

2

1 Answer 1

5

You don't need to manually replace or remove HTML, read about Character encodings in HTML

Here is the solution what you need:

System.Web.HttpUtility.HtmlDecode(input);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.