All PCRE matches are greedy, unless you make them stingy.  So .* is greedy, .*? 
is stingy

On Dec 8, 2010, at 12:02 AM, Daniel Dehennin wrote:

> Michael Potter <mega...@gmail.com> writes:
> 
>> I believe the problem is this expression:
>> 
>> "^(smtp_host)\s+.*$" replace_with => value("$(match.1) $(smtp)"),
>> 
>> Because you use a .* after the whitespace, the regex will continue to match
>> after any replacement occurs.
>> 
>> Try using a negative lookahead assertion:
>> 
>> "^(smtp_host)\s+(?!$(smtp))$"
>> 
>> This will ensure the pattern only matches when smtp_host is *not* followed
>> by $(smtp), so after the first replacement occurs, the regex will no longer
>> match and will be convergent.
> 
> Thanks, it looks like the match must be greedy.
> 
> With the normal ordering of edit_line, I finish to delete_lines that do
> not match and then insert_lines.
> 
> Thanks.
> -- 
> Daniel Dehennin
> Récupérer ma clef GPG:
> gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to