This function takes an input string, a regular expression and a replacement string as input. All sub-strings in the input string that match the regular expression are replaced by the replacement string in the output returned by this function. Note that it is the output string returned from this function that is manipulated, and that no input strings are modified.$string.replace(<inStr>, <regex>, <repStr>)
inStrregex The regular expression to apply to the string. ICU regular expressions must be used. See http://userguide.icu-project.org/strings/regexp for information.repStr For example, if you in your template reference a Composition Center text resource, then this resource will by default include a <p> and </p> tag (<p>Some text</p>). If you want to remove the <p> and </p> tags you can apply $string.replace to the text and use an empty string as replacement string:#set($text=$docdef.section1.text1)
$string.replace($text.toString(), '<p>|</p>', '')
Note: The text resource is of the type docdefResource. You must use the function toString() to convert the resource to a string ($text.toString() in example above).
Example 110 #set($text='<p>Hello world!</p>')
$string.replace($text, '<p>|</p>', '')Hello world!#set($text=$docdef.section1.text1)
Original text: $text
Manipulated text: $string.replace($text.toString(), '</?p>', '')Original text: <p>Hello world!</p>
Manipulated text: Hello world!
Example 112 #set($a='Hello Mr "Nice Guy"')
$string.replace($a, '\N{QUOTATION MARK}', '''')Hello Mr 'Nice Guy'
Example 113 #set($a='Hello
how
are
you?')
$string.replace($a, '\n', ' ')Hello how are you?
| OpenText StreamServe 5.6.2 | Updated: 2018-01-26 |