Look-ahead regex, not matching?

Bob <[email protected]> Tue, 8 Jul 2025 15:50:31 -0700 (PDT)
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
------=_Part_613444_1308092215.1752015031538
Content-Type: multipart/alternative; 
	boundary="----=_Part_613445_1068968077.1752015031538"

------=_Part_613445_1068968077.1752015031538
Content-Type: text/plain; charset="UTF-8"

I am trying to change the default screensaver. The line of interest is as 
follows:

*mode:                  random

Note: there are 3 tab characters between the colon and the word "random".

Code:

body file control
{
    inputs => { "/var/cfengine/share/CoreBase/masterfiles/lib/files.cf" };
}

body common control
{
      bundlesequence => { "example" };
}

bundle agent example
{
  files:
    linux::
      "/etc/X11/app-defaults/XScreenSaver-nogl"
      comment       => "Set screensaver mode to blank",
      edit_line     => my_replace("\*mode:\s+(?!blank)",
                                  "*mode:                       blank"),
      edit_defaults => std_defs;

}
bundle edit_line my_replace(regex,text)
{
replace_patterns:

 "^($(regex))$"

     replace_with => value("$(text)"),
          comment => "Search and replace string";
}

As best as I can tell, I am not matching the line. Any suggestions?

Using CFEngine community 3.24.1.

Thank you.

-- 
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/cc7382ba-7a5f-4399-a660-3fbb39108355n%40googlegroups.com.

------=_Part_613445_1068968077.1752015031538
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div>I am trying to change the default screensaver. The line of interest is=
 as follows:</div><div><br /></div><div><span style=3D"font-family: Courier=
 New;">*mode: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0random</span><br /></div><div><br /></div><div>Note: there are 3 tab cha=
racters between the colon and the word "random".</div><div><br /></div><div=
>Code:</div><div><br /></div><div><span style=3D"font-family: Courier New;"=
>body file control<br />{<br />=C2=A0 =C2=A0 inputs =3D&gt; { "/var/cfengin=
e/share/CoreBase/masterfiles/lib/files.cf" };<br />}<br /><br />body common=
 control<br />{<br />=C2=A0 =C2=A0 =C2=A0 bundlesequence =3D&gt; { "example=
" };<br />}<br /><br />bundle agent example<br />{<br />=C2=A0 files:<br />=
=C2=A0 =C2=A0 linux::<br />=C2=A0 =C2=A0 =C2=A0 "/etc/X11/app-defaults/XScr=
eenSaver-nogl"<br />=C2=A0 =C2=A0 =C2=A0 comment =C2=A0 =C2=A0 =C2=A0 =3D&g=
t; "Set screensaver mode to blank",<br />=C2=A0 =C2=A0 =C2=A0 edit_line =C2=
=A0 =C2=A0 =3D&gt; my_replace("\*mode:\s+(?!blank)",<br />=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "*mode: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 blank"),<br />=C2=A0 =C2=A0 =C2=A0 e=
dit_defaults =3D&gt; std_defs;<br /><br />}<br />bundle edit_line my_replac=
e(regex,text)<br />{<br />replace_patterns:<br /><br />=C2=A0"^($(regex))$"=
<br /><br />=C2=A0 =C2=A0 =C2=A0replace_with =3D&gt; value("$(text)"),<br /=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 comment =3D&gt; "Search and replace str=
ing";<br />}</span><br /></div><div><br /></div><div>As best as I can tell,=
 I am not matching the line. Any suggestions?</div><div><br /></div><div>Us=
ing CFEngine community=C2=A03.24.1.</div><div><br /></div><div>Thank you.</=
div><div><br /></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;help-cfengine&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">help-=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
help-cfengine/cc7382ba-7a5f-4399-a660-3fbb39108355n%40googlegroups.com?utm_=
medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/help-=
cfengine/cc7382ba-7a5f-4399-a660-3fbb39108355n%40googlegroups.com</a>.<br /=
>

------=_Part_613445_1068968077.1752015031538--

------=_Part_613444_1308092215.1752015031538--