Re: Look-ahead regex, not matching?

Nick Anderson <[email protected]> Tue, 8 Jul 2025 17:54:48 -0700 (PDT)
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
------=_Part_11906_369378864.1752022488888
Content-Type: multipart/alternative; 
	boundary="----=_Part_11907_780049545.1752022488888"

------=_Part_11907_780049545.1752022488888
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Bob,

Try       edit_line     =3D> my_replace("\*mode:\s+(?!blank$)"

On Tuesday, July 8, 2025 at 5:50:31=E2=80=AFPM UTC-5 Bob wrote:

> I am trying to change the default screensaver. The line of interest is as=
=20
> follows:
>
> *mode:                  random
>
> Note: there are 3 tab characters between the colon and the word "random".
>
> Code:
>
> body file control
> {
>     inputs =3D> { "/var/cfengine/share/CoreBase/masterfiles/lib/files.cf"=
 };
> }
>
> body common control
> {
>       bundlesequence =3D> { "example" };
> }
>
> bundle agent example
> {
>   files:
>     linux::
>       "/etc/X11/app-defaults/XScreenSaver-nogl"
>       comment       =3D> "Set screensaver mode to blank",
>       edit_line     =3D> my_replace("\*mode:\s+(?!blank)",
>                                   "*mode:                       blank"),
>       edit_defaults =3D> std_defs;
>
> }
> bundle edit_line my_replace(regex,text)
> {
> replace_patterns:
>
>  "^($(regex))$"
>
>      replace_with =3D> value("$(text)"),
>           comment =3D> "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.
>
>

--=20
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 e=
mail to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/help-cfengi=
ne/e632fd3e-2ec1-480a-a597-08e5f6c36d47n%40googlegroups.com.

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

<div>Hi Bob,</div><div><br /></div><div>Try=C2=A0<span style=3D"font-family=
: Courier New;">=C2=A0 =C2=A0 =C2=A0 edit_line =C2=A0 =C2=A0 =3D&gt; my_rep=
lace("\*mode:\s+(?!blank$)"</span></div><br /><div class=3D"gmail_quote"><d=
iv dir=3D"auto" class=3D"gmail_attr">On Tuesday, July 8, 2025 at 5:50:31=E2=
=80=AFPM UTC-5 Bob wrote:<br/></div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0 0 0 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding=
-left: 1ex;"><div>I am trying to change the default screensaver. The line o=
f interest is as follows:</div><div><br></div><div><span style=3D"font-fami=
ly: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 =
characters between the colon and the word &quot;random&quot;.</div><div><br=
></div><div>Code:</div><div><br></div><div><span style=3D"font-family:Couri=
er New">body file control<br>{<br>=C2=A0 =C2=A0 inputs =3D&gt; { &quot;/var=
/cfengine/share/CoreBase/masterfiles/lib/<a href=3D"http://files.cf" target=
=3D"_blank" rel=3D"nofollow" data-saferedirecturl=3D"https://www.google.com=
/url?hl=3Den&amp;q=3Dhttp://files.cf&amp;source=3Dgmail&amp;ust=3D175210514=
5541000&amp;usg=3DAOvVaw3qW9q8hYaw_WFfrnBBmMXt">files.cf</a>&quot; };<br>}<=
br><br>body common control<br>{<br>=C2=A0 =C2=A0 =C2=A0 bundlesequence =3D&=
gt; { &quot;example&quot; };<br>}<br><br>bundle agent example<br>{<br>=C2=
=A0 files:<br>=C2=A0 =C2=A0 linux::<br>=C2=A0 =C2=A0 =C2=A0 &quot;/etc/X11/=
app-defaults/XScreenSaver-nogl&quot;<br>=C2=A0 =C2=A0 =C2=A0 comment =C2=A0=
 =C2=A0 =C2=A0 =3D&gt; &quot;Set screensaver mode to blank&quot;,<br>=C2=A0=
 =C2=A0 =C2=A0 edit_line =C2=A0 =C2=A0 =3D&gt; my_replace(&quot;\*mode:\s+(=
?!blank)&quot;,<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 &quot;*mode:=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 blank&quot;),<br>=C2=A0 =C2=A0 =C2=A0 edit_defaults =3D&gt; std_defs;<b=
r><br>}<br>bundle edit_line my_replace(regex,text)<br>{<br>replace_patterns=
:<br><br>=C2=A0&quot;^($(regex))$&quot;<br><br>=C2=A0 =C2=A0 =C2=A0replace_=
with =3D&gt; value(&quot;$(text)&quot;),<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 comment =3D&gt; &quot;Search and replace string&quot;;<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>Using CFEngine community=C2=A03.=
24.1.</div><div><br></div><div>Thank you.</div><div><br></div></blockquote>=
</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/e632fd3e-2ec1-480a-a597-08e5f6c36d47n%40googlegroups.com?utm_=
medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/help-=
cfengine/e632fd3e-2ec1-480a-a597-08e5f6c36d47n%40googlegroups.com</a>.<br /=
>

------=_Part_11907_780049545.1752022488888--

------=_Part_11906_369378864.1752022488888--