[augeas-devel] Matching key/value statement

Mol, Xavier (SCC) xavier.mol at kit.edu
Fri Oct 30 08:13:41 UTC 2015


Hi Yclept,



do I understand your proposed match correctly in that only the key node and a '=' sign are guaranteed to exist? Appart from that, try 
using variables and functions from the generic modules coming with Augeas. That does ease development for you and avoids 
misunderstandings on this list. E.g. does this maybe already match your pattern (you have not given a regular expression to match 
"key", "value" or "comment", so I just assume you want to match a simple word and comments are started with '#')?



let match = [ Util.del_opt_ws . key  Rx.word . Sep.space_equal . (store Rx.word)? . Util.comment_or_eol ]



I haven't tested this, since you did not give a real word example either, so try it for yourself.



Ciao,

Xavier.





From: augeas-devel-bounces at redhat.com [mailto:augeas-devel-bounces at redhat.com] On Behalf Of Yclept Nemo
Sent: Friday, October 30, 2015 2:18 AM
To: augeas-devel
Subject: [augeas-devel] Matching key/value statement



How to unambiguously match:

    # spaces? key spaces? = spaces? value? spaces? comment?

where "key" is the node key, "value" the node value, and "comment" and child node?


These are all accurate but create ambiguities in the put direction:

    = (spaces | ((spaces? . value)? . (spaces? . comment)?))

    = spaces? . (value | comment | (value . spaces? . comment?))?

    = (spaces? | (spaces? . value) | (spaces? . comment) | (spaces? . value . spaces? . comment))

... whether or not the union branches occur on the lens or node level.

Sincerely,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20151030/8a513107/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6401 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20151030/8a513107/attachment.p7s>


More information about the augeas-devel mailing list