Question

I have tried the following to no avail

var clean = link.replace(/\&nbsp\; /gi,' ');

I have also tried without escaping both the & and ; and escaping only one but it doesn't work. I can replace just plain nbsp. Is there any way to replace   with just ' '?

Was it helpful?

Solution

I've been working on this with some people over on the Appcelerator Q&A and the best answer I could come up with is a work around at best.

var clean = link.replace(/nbsp/g," ").replace(/\&/g,"").replace(/amp\;/g,"").replace(/\;/g,"");

For obvious reasons this won't work for everybody since it will wipe out all semicolons and ampersands but it worked for me. I'm perplexed as to why I can't get the entire   replaced but for now I'm happy.

OTHER TIPS

If you want to replace   with an empty string containing space ' ' entirely, just use:

var clean = link.replace(/ /g,' ');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top