I have following file .active{ color:#333333; } input,select,.titulo1{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; } textarea{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; border: 1px solid #000000; } td,.Estilo1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } hr { line-height: 1px; color: #000000; } Code (markup): I need to extract only css class not other thing like ID etc. That means I need all those thing that are start with dot(.). Desired Output of above code: .active{ color:#333333; } input,select,.titulo1{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; } Code (markup): Since .active is the only css class. \ Please help to give me a pattern Thanks
If .active is the only CSS class, then why is your desired output: ...? .active is just: .active{ color:#333333; } Code (markup): Anyway, this seems to work for me: '~(?:^|[\s\}>])((\.[\w-]+)\s*\{[^\}]+\})~' PHP: (Assuming you JUST want to get .active, in this case.)
<?php $x = ".active{ color:#333333; } input,select,.titulo1{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; } textarea{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; border: 1px solid #000000; } td,.Estilo1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } hr { line-height: 1px; color: #000000; }"; preg_match_all("/(\,|\..*?)\{/si",$x,$y); print_r($y); ?> PHP: try that RETURNS Array ( [0] => Array ( [0] => .active{ [1] => .titulo1{ [2] => .Estilo1 { ) [1] => Array ( [0] => .active [1] => .titulo1 [2] => .Estilo1 ) )