Trim and tags from String java or javascript

I want to remove the start and trailing br and nbsp tags from a string using java or javascript.

The input and the desired output are hosted in jsfiddle.net because Stackoverflow does not allow me to host html content.

http://jsfiddle.net/HwDf9/

+4
source share
1 answer

Something like that?

request.replace(/^\&nbsp\;|<br?\>*/gi, "").replace(/\&nbsp\;|<br?\>$/gi, "").trim(); 
+8
source

All Articles