actually it is very trivial.

just use a regular expression to match the part of the string excluding the
comment, and then replace the string with $(match.1)

i.e. if a commented line was:

# username=password

You could use a regex like:

#\s+(.*)

And replace it with

$(match.1)

to get

username=password

I think I have a generic function called replace_with_first_match for this
kind of thing

On Fri, Dec 18, 2009 at 2:08 PM, Jessica Greer <[email protected]>wrote:

> Can I get examples of uncommenting lines from other cf3 users?
>
> Commenting is straightforward with replace_with, but uncommenting seems
> non-trivial.  I thought about using getfields(), using my comment character
> as a delimiter, to stuff the remainder of the line into a variable I could
> then use with replace_with.  The getfields() function doesn't seem to be
> implemented, though (no matter; it was a messy solution anyhow).
>
> I could delete the commented line and replaced with an uncommented one - is
> that what others are doing, or am I missing a simpler way?
>
> Thanks,
> -Jess
>
>
> _______________________________________________
> Help-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/help-cfengine
>
>
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to