Regular expression help

Status
Not open for further replies.

Mobius

In Runtime
Messages
148
Location
Toronto, Canada
Hi guys,

I was wondering if any of you know how I can use regular expression to extract the style attribute out of an html tag

for example:

<p style="blah" class="blah">

I want the result to be style="blah" i tried different ones and ended up with including the last occurence of double quote, so it gave me class="blah" as well.

any help would be great!

Thank you
Mobius
 
oh man you rock care to explain why it works if you don't mind?

i did some test with RAD software regular expression designer and so far so good!
 
ahh i had this before style=".*" but got more than its suppose to, where as yours just knows to stop at the first closing double quote tag
 
You could use the * to match style="" if you like. Having thought about it you don't really get spaces in attributes but in the style attribute you do get : and ; which my fist expression will not catch.
Try style="[^"]*" (if you want style="" to be caught) or style="[^"]+" (if you don't) instead. These ones will catch spaces but they will also catch more than just alphanumeric words as well.
 
Status
Not open for further replies.
Back
Top Bottom