regexampersand

Replace &amp or multiple &amp using regex


if only one &amp I could use

value = value.Replace("&","&")

but as per checking the data, some has "&amp" and many more.

Why is it decoded with multiple amp when original text is only one "&"?

I'm not a regex expert, I'd like to seek help to just create a regex that would decode it to only one ampersand.

Many thanks for those who will help :) Thanks


Solution

  • You can try to search for:

    &(amp;)+
    

    so:

    value = value.Replace("&(amp;)+","&")