[augeas-devel] Regular expression matching in path expressions

Matthew Palmer matt at anchor.net.au
Wed Sep 16 21:02:12 UTC 2009


On Wed, Sep 16, 2009 at 10:47:17AM -0700, David Lutterkort wrote:
> In a nutshell, I am looking for a different notation for literal
> regexps, one that fits well into the path expression language, but is
> also not so weird that nobody will ever be able to remember it. Options
> as far as I can see:
> 
>       * Use a function that turns a string -> regexp, i.e. something
>         like "regexp('eth:[0-9]+')"

+0.5.  It's relatively neat and clean, and makes it *very* clear what's
happening (it says regexp right there -- it's a terminally clueless
individual who doesn't make the connection).

>       * Ruby-like notation: "%r{eth:[0-9]+}"

+0.75.  I'm familiar with this, so it looks natural, and it is more concise
than a full-blown regexp().  However, it's not *obvious* what it's doing
(although the 'r' and regex-y contents would be a fair clue).

>       * Some other delimiter than '/', e.g. "@eth:[0-9]+"

-\inf{}.  This suffers from being utterly unique to Augeas (AFAIK everyone
uses // for regexes, if they support them as first-class entities in the
language) and hence lacks any existing familiarity for anyone to draw on.
Whatever character you choose will almost certainly bump up against
something that's used somewhere, confusing people and requiring a mental
gear change for escaping ("oh yeah, Augeas uses $RANDOM_CHARACTER for regexp
deliniation; I have to remember to escape $RANDOM_CHARACTER in my regexps
instead of /").  No thanks.

> Any opinions on that ? Does anybody know of any commonly-used notation
> not covered by the above ?

Nothing that isn't infinitely less functional than the possibilities already
covered (like languages where regexes are second-class citizens -- Python,
I'm glaring at you).

- Matt




More information about the augeas-devel mailing list