[Mapcss] Regexp as attribute selection
Richard Fairhurst
richard at systemeD.net
Mon Jul 19 08:44:33 BST 2010
Chris Browet wrote:
> In the doc, it is described that regexp attribute selection is allowed
> ("way[highway=~/primary/] /* regex */").
>
> While it is inherently nice, the problem is that there is almost as many
> regexp syntaxes as there are implementations.
> At least, the syntax used should be defined (is the example perl?) but I
> doubt it will be practical to implement a specific syntax for MapCSS in
> every programming language (not even speaking of those not having
> builtin support).
>
> Shouldn't it be wise to remove this from the spec and replace it by
> simpler cardinals ('*', '?' and maybe others)?
I'd strongly like to stick with regexes.
They are built into many languages and available as a library for
others. If we require people to build their own pattern matchers, that
will make it harder for people to implement MapCSS parsers.
PCRE is a widely-used regex standard which we could recommend. Any
differences are usually reasonably trivial and esoteric (for example,
http://www.mail-archive.com/develop@xcruciate.co.uk/msg00031.html only
lists two edge cases in which PCRE differs from JavaScript/ECMAScript).
Wikipedia suggests this will give us widespread compatibility: "Java,
JavaScript, PCRE, Python, Ruby, Microsoft's .NET Framework, and the
W3C's XML Schema all use regular expression syntax similar to Perl's.
Some languages and tools such as Boost and PHP support multiple regular
expression flavors".
cheers
Richard
More information about the Mapcss
mailing list