W3C home > Mailing lists > Public > www-style@w3.org > August 2001

Regular Expressions as CSS Selectors?

From: Claus Färber <list-w3c-style@faerber.muc.de>
Date: 13 Aug 2001 12:58:00 +0200
To: www-style@w3.org
Message-ID: <86oRfgd3cDB@3247.org>
Hallo,

what about adding regular expressions to the CSS selector syntax?

This way, one could reference parts of element content that are
not marked as subelements.

For example:

h1 /W3C/        {color:blue}
/W3C/           {content:url('w3clogo.svg');height:1em}

Of course, the regexp syntax is much more powerfull than just
matching fixed text strings:

/\<-[0-9]{1,2}([0-9]{3})*(\.[0-9]+\)?\>/  {color:red}

Of course, regexps should also be allowed in attribute selectors:

h1[class=/^head.*/]

Regexps could also use to replace the *=, ^= and $= syntax from
the CSS3 draft:

element[attribute="bla"]        =>      element[attribute=/^bla$/] /* !!! */

element[attribute*="bla"]       =>      element[attribute=/bla/]
element[attribute^="bla"]       =>      element[attribute=/^bla/]
element[attribute$="bla"]       =>      element[attribute=/bla$/]

It could, in conjunction with the content property, be even used
to rewrite the document's text (in some limited way):

/W3C/   {content: "World Wide Web Consortium"}
/(A)(B)(C)/ {content: $3 $1 $2}

Claus
-- 
begin  Your-so-called-newsreader-is-seriously-broken
unless you can read this.
end
                                                    http://www.faerber.muc.de
Received on Monday, 13 August 2001 07:02:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:10 GMT