Sorry i'm new for regexp, so i need a regexp for this type of tag, exactly for this:
<p style="font-family: Georgia;">Text</p>
I have a regexp that suits for all p tags, regexp for all p tag is: <\s*p[^>]*>([^<]*)<\s*\/\s*p\s*>/
found it on this site. I tried to figure out by myself, i wrote this: <\s*p[\"\^font\-\family\:\()\Georgia开发者_运维技巧\;\$\"\]*>([^<]*)<\s*\/\s*p\s*>/
but i know it's wrong can anyone help me :) I need regexp exactly for this piece: style="font-family: Georgia;"
Thank you.
If you just want to match style="font-family: Georgia;" use this: \w+=".+"
For matching the the entire thing \s*<p \w+=".+">([^<]*)</p>\s*
can do the trick. This will capture all paragraphs with exactly one attribute with a quoted value.. Not really flexible. If you only want to capture on paragraphs with exactly the font-family georgia style use \s*<p style="font-family: Georgia;">([^<]*)</p>\s*
If you find yourself using a lot of regular expressions to "parse" html, a HTML parser might save yourself a lot of trouble. Php's DOM class can parse html.
精彩评论