On Mar 7, 2009, at 4:20 PM, ricardobeat wrote:


this seems to work:

scrubbed = code.html().replace(/<!--[^-->]*-->/gi,"");

I don't think that is going to work, either (at least, it didn't for me in firebug). You're probably expecting the character set, [^-->], to negate the string "-->", but it doesn't work that way. Instead, it negates "-" and ">".

The expression you had would eat everything between the first "<!--"
and the last "-->". There's probably a more elegant way to do it, but
I can't help any further.

It'll eat the first "<!--" and the last "-->", along with everything in between. ;)

This should work:

scrubbed = code.html().replace(/<!--.*?-->/gi,"");

It might be kind of slow if you throw a ton of html at it.


--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com

Reply via email to