Re: Look-ahead regex, not matching?
"'Nick Anderson' via help-cfengine" <[email protected]> Wed, 09 Jul 2025 09:13:06 -0500
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
--=-=-= Content-Type: multipart/alternative; boundary="==-=-=" --==-=-= Content-Type: text/plain; charset="UTF-8" Respond to Bob <[email protected]>: [help-cfengine] Re: Look-ahead regex, not matching? :email: ======================================================================================== Hey Bob, When I change it to this, it works: edit_line => my_replace("\*mode:\s+(?!blank.*).*", "*mode: blank"), In my short test file, it works just fine. However, when I add it to my site.cf file: error: Promised replacement '*mode: blank' for pattern '^(\* mode:\s+(?!blank.*).*)$' is not properly convergent while editing '/etc/X11/app- defaults/XScreenSaver-nogl' (pattern still matches the end-state replacement string '*mode: blank', consider use of a negative look ahead) error: Errors encountered when actuating replace_patterns promise '^(\*mode:\ s+(?!blank.*).*)$' What could be the difference? I think it should be like this: ,---- | edit_line => my_replace("\*mode:\s+(?!blank$).*$", `---- But, I think that this might be of use to you as well: <https://gist.github.com/nickanderson/1ffd7936b66b4a7c1e703fbbdc49e0d1> -- You received this message because you are subscribed to the Google Groups "help-cfengine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/help-cfengine/87cya9sb8l.fsf%40northern.tech. --==-=-= Content-Type: text/html; charset="UTF-8" <p> Hey Bob, </p> <blockquote style="border-left: 2px solid gray; padding-left: 4px;"> <p> When I change it to this, it works: </p> <p> edit_line => my_replace("\*mode:\s+(?!blank.*).*", "*mode: blank"), </p> <p> In my short test file, it works just fine. However, when I add it to my site.cf file: </p> <p> error: Promised replacement '<b>mode: blank' for pattern '^(\</b> mode:\s+(?!blank.*).*)\(' is not properly convergent while editing '/etc/X11/app- defaults/XScreenSaver-nogl' (pattern still matches the end-state replacement string '*mode: blank', consider use of a negative look ahead) error: Errors encountered when actuating replace_patterns promise '^(\*mode:\ s+(?!blank.*).*)\)' </p> <p> What could be the difference? </p> </blockquote> <p> I think it should be like this: </p> <pre class="example" id="orgc0270d6"> edit_line => my_replace("\*mode:\s+(?!blank$).*$", </pre> <p> But, I think that this might be of use to you as well: <a href="https://gist.github.com/nickanderson/1ffd7936b66b4a7c1e703fbbdc49e0d1">https://gist.github.com/nickanderson/1ffd7936b66b4a7c1e703fbbdc49e0d1</a> </p> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups "help-cfengine" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:[email protected]">[email protected]</a>.<br /> To view this discussion visit <a href="https://groups.google.com/d/msgid/help-cfengine/87cya9sb8l.fsf%40northern.tech?utm_medium=email&utm_source=footer">https://groups.google.com/d/msgid/help-cfengine/87cya9sb8l.fsf%40northern.tech</a>.<br /> --==-=-=-- --=-=-= Content-Type: text/plain; charset="UTF-8" -- Nick Anderson | Doer of Things | (+1) 785-550-1767 | https://northern.tech -- You received this message because you are subscribed to the Google Groups "help-cfengine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/help-cfengine/87cya9sb8l.fsf%40northern.tech. --=-=-=--