Proposal: regular expressions (or wildcards) in selectors

Especially with browsers which for some reason do not understand how to 
handle elements with multiple classes in HTML, some people wish there 
was a way to have some kind of wildcard in an ID or class selector.
Allowing regular expressions would possibly help a little.

*[class=regexp(/myclass-(a|b)[0-9]+/)] {
     /* ... */
}

This would match any element with a class of "myclass-a" or "myclass-b" 
followed by any amount of digits.
This might however result in parsing errors with older browsers and thus 
not be backwards compatible.


For now a wildcard character would be enough, eg:

.myclass-a~5 {
     /* ... */
}

or

*[class=myclass-a~5] {
     /* ... */
}

for any class that begins with "myclass-a" and ends with a 5.
As this wildcard would have to be a symbol which does not occur 
elsewhere, it couldn't break the stylesheet for older browsers.

If it hadn't been made publically available with the errata of the last 
version, the character _ (underscore) could serve this purpose.


Yours,

Alan Plum

Received on Tuesday, 16 March 2004 12:37:28 UTC