For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > September 2005 > preg_match_all() and css classes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author preg_match_all() and css classes
kevinC

2005-09-12, 6:55 pm

Hello,

I'm trying to parse out the properties of a class definition from a css
file and am running into issues trying to write the reg. expression:

h1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold;
color: #003399;
}
....

I need the results in:
array[i][0] = "h1"
array[i][1] = "
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold;
color: #003399;"

Any idea? I tried looking online for an example and can't find anything
that works with php's preg_match_all() function...

Thank you in advance!

-Kevin

Oli Filth

2005-09-12, 6:55 pm

kevinC said the following on 12/09/2005 21:39:
> Hello,
>
> I'm trying to parse out the properties of a class definition from a css
> file and am running into issues trying to write the reg. expression:
>
> h1 {
> font-family: Verdana, Arial, Helvetica, sans-serif;
> font-size: 16px;
> font-weight: bold;
> color: #003399;
> }
> ...
>
> I need the results in:
> array[i][0] = "h1"
> array[i][1] = "
> font-family: Verdana, Arial, Helvetica, sans-serif;
> font-size: 16px;
> font-weight: bold;
> color: #003399;"
>
> Any idea? I tried looking online for an example and can't find anything
> that works with php's preg_match_all() function...
>



preg_match_all('/\s*(.*)\s*\{\s*(.*)\s*\}/sU', $str, $array,
PREG_SET_ORDER);


--
Oli
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com