user2450064
user2450064

Reputation: 113

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

Upvotes: 1

Views: 2692

Answers (2)

Cake Princess
Cake Princess

Reputation: 217

In JavaScript, as long as it is a String, you can use:

value = value.replaceAll("&", "&");

This is strictly for the exact string "& amp ;" though.

Upvotes: 0

hsz
hsz

Reputation: 152216

You can try to search for:

&(amp;)+

so:

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

Upvotes: 1

Related Questions