Friday 22 July 2011

A Javascript regexp for getting tags out of a textarea

If you are ever faced with , as I was recently, with a loading a text area with some text that has HTML tags in it and you want to get rid of them for say an abstract and you can't be arsed going back to the server here is a wee Javascript function that will do the job for you.

function fStripTags(a)
    b =  a.replace(/<\/?[^>]+>/gi, '')
    return b;

Disqus for Domi-No-Yes-Maybe