Replaces the first occurrence matching the target string by the replacement string in the base string.
The replacement proceeds from the beginning of the string to the end, for example, replacing “aa” with “b” in the string “aaa” will result in “ba” rather than “ab”.
String
replace(<parameters>)
Parameter | Type |
---|---|
base | string |
target | string (RegExp) |
replacement | string |
replace(<base>,<target>,<replacement>)
Return a string.
replace("Hello World", "l", "x")
Returns “Hexlo World”.
Because the target parameter is a RegExp, depending on the string you want to replace, you may need to escape some characters. Here is an example:
|OFFER_A|OFFER_B
#{ExperiencePlatform.myFieldGroup.profile.myOffers}
|OFFER_A
''
\\
before the |
character.The expression is:
replace(#{ExperiencePlatform.myFieldGroup.profile.myOffers}, '\\|OFFER_A', '')
The returned string is: |OFFER_B
You can also build the string to be replaced from a given attribute:
replace(#{ExperiencePlatform.myFieldGroup.profile.myOffers}, '\\|' + #{ExperiencePlatform.myFieldGroup.profile.myOfferCode}, '')