W3C home > Mailing lists > Public > www-style@w3.org > March 1998

Re: OPINIONS WANTED: regexps in CSS?

From: William M. Perry <wmperry@aventail.com>
Date: Wed, 11 Mar 1998 16:08:01 -0500 (EST)
Message-ID: <86k9a1rl5i.fsf@kramer.bp.aventail.com>
To: Bert Bos <Bert.Bos@sophia.inria.fr>
Cc: <www-style@w3.org>
Bert Bos <Bert.Bos@sophia.inria.fr> writes:

> Frank Boumphrey writes:
>  > >>Only the "advanced" users are going to be inventing DTDs for their XML yet
>  > this has been accepted by the W3C. For the more complicated features, the
>  > less advanced users will simply use authoring tools which write the regexp
>  > for them.<<
>  > 
>  > This discussion has centered on the user, but remember the developer.
>  > One of the nice things in the XML spec was that it was stated "It
>  > shall be easy to write programs for XML"
>  > 
>  > If regexp becomes part of the CSS specification, then a whole new
>  > layer of complexity is added to any program that is written for the
>  > standard, and automatically it means that only those companies that
>  > have the resources can support them. That means that prices go up
>  > etc. etc.
> 
> On a related note, a programmer here noted that regexps could become
> quite costly in execution time as well. For a very simple document (3
> paragraphs, 6 list items, 2 classes, and the sample style sheet from the
> spec + 2 more rules), there were already some 70,000 comparisons involved
> in matching selectors against elements. At the moment they are all
> hashcodes (i.e., comparing one integer against another), so they are
> fast, but you can imagine what will happen if some of the selectors
> contain regexps.

  Regular expressions are not that expensive if you precompile them and
just keep the regex_t hanging around instead of the much less efficient way 
of just recompiling the regexp every time.  This is similar to what the
perl 'study' command does for regexps I believe.

  And like someone pointed out before, regular expressions have been around 
for years, and highly efficient (and free :) implementations exist for just 
about any platform.  I personally use regexps on 15 different platforms
(mostly unix, but occasionally crosses over to NT/95 just fine) in my own
programs.

-Bill P.
Received on Wednesday, 11 March 1998 16:28:38 GMT

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