Alex Rivera | Logout

How to replace   to space?

Asked 2010-09-14T12:13:30.717
18

Content is

    Hello World.

<a&nbsp;href="#"&nbsp;target=_blank>hello&nbsp;World</a>

How to replace the &nbsp; in html code and keep the other &nbsp; in the text.

Edit
Report

1 Answer

4

Can you try searching for

(?<=<[^>]*)&nbsp;

and replacing it with a single space?

This looks for &nbsp; inside tags (preceded by a < and possibly other characters except >).

This is extremely brittle, though. For example, it will fail if you have </> symbols in strings/attributes. Better avoid getting those &nbsp; into the wrong locations in the first place.

answered 2010-09-14T12:30:56.967

Your Answer