[augeas-devel] Regular expression matching in path expressions
David Lutterkort
lutter at redhat.com
Wed Sep 16 17:47:17 UTC 2009
I need to add some sort of substring/regexp matching to path
expressions. For example, I'd like to pick out all the aliases for
network interface eth0; they have an entry 'DEVICE=eth:N' where N is
some number. Ideally, I could say
match /files/etc/sysconfig/network-scripts/*[DEVICE =~ /eth:[0-9]+/]
That causes some syntactic headache, though, since the notation /RE/ for
regexps is too close to normal paths, and it becomes very hard to tell
whether
defvar x /foo/
defines a regular expression or a nodeset.
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]+')"
* Ruby-like notation: "%r{eth:[0-9]+}"
* Some other delimiter than '/', e.g. "@eth:[0-9]+"
Any opinions on that ? Does anybody know of any commonly-used notation
not covered by the above ?
David
More information about the augeas-devel
mailing list