Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/02/2010, 16:21
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 2 meses
Puntos: 20
Problema para diferenciar propiedades HTML, CLASS, ID (Reg Expresions)

Buenas,

En un código CSS como este, necesito ser capaz de separar los elementos por si son

HTML (no llevan ni punto ni # delante)
CLASS (llevan un punto delante)
ID(llevan una # delante)

Ejemplo:
Código CSS:
Ver original
  1. body#help #content ul#helpCategories {
  2.     margin: 5px 0 0 0;
  3.     padding: 0;
  4.     list-style: none; }
  5.    
  6. #footer #footerGlobalNav ul li.first {
  7.     border-left: none;
  8. }
  9. .multipleColumns #pageContent-main, #pageContent-second {
  10.     width: 305px;
  11.     float: left;
  12. }

Me debería decir para la primera propiedad que

body#help #content ul#helpCategories {
HTML = body y ul
CLASS = no hay clases
ID = help, content y helpCategories


#footer #footerGlobalNav ul li.first {
HTML = ul y li
CLASS = first
ID = footer y footerGlobalNav


.multipleColumns #pageContent-main, #pageContent-second {
HTML = ninguna
CLASS = multipleColumns
ID = pageContent-main y pageContent-second


La expresión regular me selecciona todo lo que hay desde comienzo de linea hasta el signo {

preg_match_all("/[\.#\s\w:-]*\w[,\s+]+[:\.#\s\w:-]*\{/is",$linea,$matches)

Por lo que del resultado,

body#help #content ul#helpCategories {
#footer #footerGlobalNav ul li.first {
.multipleColumns #pageContent-main, #pageContent-second {


solo queda hacer la parte de diferenciar cuales son HTML, CLASS e ID, y no se como hacerlo de una manera que funcione para los 3 casos.

¿Se os ocurre algo?

Muchas gracias de antemano!