Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim &nbsp; and <br> tags from String java or javascript

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

Input and desired output are hosted in jsfiddle.net because Stackoverflow is not letting me to post html content.

http://jsfiddle.net/HwDf9/

like image 231
sathis Avatar asked Feb 23 '23 00:02

sathis


1 Answers

Something like this?

request.replace(/^\&nbsp\;|<br?\>*/gi, "").replace(/\&nbsp\;|<br?\>$/gi, "").trim();
like image 108
betamax Avatar answered Feb 25 '23 16:02

betamax