[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Parenthesised subexpressions in ReplaceAll for cfengine-2.0.a11

From: Ronan KERYELL
Subject: Parenthesised subexpressions in ReplaceAll for cfengine-2.0.a11
Date: 10 Jul 2001 12:18:54 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

I've added some code to deal with the parenthesised subexpressions in the
right hand part of the substitution to behave as in (s)ed, vi, emacs,
perl,... The diff file is attached.

It should avoid most of external editing (at least for me, I no longer
need external editing with this new behaviour).

Here is the modification of the doc I propose (ie by adding a paragraph and
an example)  :

ReplaceAll quoted-regex With quoted-string 

      Replace all instances of strings matching the regular expression in
the first quotes with the exact string in the second set of quotes,
      throughout the current file. Note that cfengine matches on a left to 
right basis, with the first match taking precedence, so if your
      regular expression matches text ambiguously it is the first occurrence 
which is replaced. For example, if you replace cf.* with
      CFENGINE and cfengine encounters a line hello cfengine cfengine, then 
this will be replaced with hello CFENGINE even though two
      possible strings match the regular expression. On the other hand if the 
expression is not ambiguous, say replacing cfengine with
      CFENGINE, then the result would be hello CFENGINE CFENGINE. 

      Parenthesised subexpressions can be used in quoted-string in the
same way as in quoted-regex : \3 expands for example to the third parenthesised 
subexpression. The special \0 subexpression matches for all the match.

For example :

      { /etc/vfstab
         # To use logging ufs file systems:
         ReplaceAll '^(/dev/.*[ $(tab)]ufs[ $(tab)].*)-$' With '\1logging'

    Ronan KERYELL              |\/
    Labo Informatique Télécom  |/)  Tel:    (+33|0)
    ENST Bretagne, BP832       K    Fax:    (+33|0)
    29285 BREST CEDEX          |\   E-mail: address@hidden
    FRANCE                     | \  http://www-info.enst-bretagne.fr/~keryell

Attachment: item-ext.diff
Description: Difference from cfengine-2.0.a11/src/item-ext.c

reply via email to

[Prev in Thread] Current Thread [Next in Thread]