Say I have an element in my HTML page like so:
<span class="special caption['This <em>expression</em> describes this element.']">ABC</span>
I’d like to use jQuery to extract this “caption” from the class attribute. I know how to isolate
caption['This <em>expression</em> describes this element.']
but what regular expression could let me extract
This <em>expression</em> describes this element.
?
Bonus points if I can incorporate an escape sequence for the apostrophe, e.g.
caption['This <em style=\'color: #FF0000;\'>expression</em> describes this element.']
and get
This <em style=’color: #FF0000;’>expression</em> describes this ‘element.’
Thanks for all your help. I’m really challenged at regular expressions….
You probably shouldn’t be putting this info into the class attribute (see locrizak’s answer), but if you absolutely have to for some reason, read on.
I don’t think you need a regular expression. If you already know how to get it down to this:
…then all you need to do is take that string and substring it, like so: