views:

32

answers:

1

Can I use Character Encoding for Regular Expressions...?

e.g.

this.html().replace(/<\/?[^>]+>/gi, '')

Instead of:

this.html().replace(/<\/?[^>]+>/gi, '')
+2  A: 

Define "use" ..

Inside a regex literal, &lt; will never translated or considered the same as <. That doesn't mean you can't use it in your expression, it just means you'll be matching &lt; rather than <

var x = "<html>";

x.match('<[^>]+>'); // => <html>
x.match('&lt;[^>]+>'); // => null
Matt