I feel like I'm missing something really obvious here:  is there a way
to do basic string search and replacement?

For example, I have a string "foo:bar:baz", and I want to convert ":ba"
into "-DA".  Thus, the output string would be "foo-DAr-DAz".  This is
trivial in perl/sed/awk, but I can't find anything in native CF3 that
will do this (despite it being linked against libpcre).

I'd expect something like the snippet below, but I can't find it.

vars:
        'orig' string => 'foo:bar:baz';
        'new'  string => regex_replace(${orig}, ":ba","-DA");

Right now, I'm shelling out to sed, but this seems...silly.

vars:
     'orig' string => 'foo:bar:baz';
     "new"  string => execresult("/bin/echo ${orig} | /bin/sed 's,:ba,-DA,g;'", 
"useshell");



-- 
Jesse Becker
NHGRI Linux support (Digicon Contractor)
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to