Cernunnos Manual


<string-replace>

Description:

Replaces each occurance of REGEX in the specified STRING with the specified REPLACEMENT. The resulting String will be registered as the 'Attributes.STRING' request attribute.

Reagents:

Name XPath Description Reagent Type Expected Type Required
STRING @string The String upon which replacement will be performed. The default is the value of the 'Attributes.STRING' request attribute. PHRASE java.lang.String No
REGEX @regex Regular expression to which STRING will be matched. All occurances of REGEX will be replaced with REPLACEMENT. PHRASE java.lang.String Yes
REPLACEMENT @replacement Characters that will replace matches of REGEX. PHRASE java.lang.String Yes
DOTALL @dotall If true (the default), the expression '.' matches any character, including a line terminator. PHRASE java.lang.Boolean No
SUBTASKS * The set of tasks that are children of this task. NODE_LIST java.util.List No

Examples:

Reads the file 'example.txt' into a String, replaces all instances of 'foo' with 'bar' and all instances of 'abc' with 'xyz' in the text, then writes the result back to 'example.txt':

 
       
        <with-attribute key="Attributes.STRING" value="${contents(example.txt)}"> 
          <string-replace regex="foo" replacement="bar"> 
            <string-replace regex="abc" replacement="xyz"> 
              <write-file file="example.txt"/> 
            </string-replace> 
          </string-replace> 
        </with-attribute>