Re: OPINIONS WANTED: regexps in CSS?

Bert Bos <> 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

-Bill P.

Received on Wednesday, 11 March 1998 16:28:38 UTC