Tuesday, March 10, 2009

js regexp to remove a tags from string

If you need to replace a bunch of <a> tags in your page with the innerText you can use replace with regular expressions.
"<a href=.....>Some Text</a>".replace(/<a[^>]*>([^<]*)<\/a>/gi, "$1");
I had to use this for generating a printer friendly version of a page.

0 comments:

Post a Comment