replace
- Topics:
- Journeys
CREATED FOR:
- Experienced
- Developer
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”.
Category
String
Function syntax
replace(<parameters>)
Parameters
Parameter | Type |
---|---|
base | string |
target | string (RegExp) |
replacement | string |
Signature and returned type
replace(<base>,<target>,<replacement>)
Return a string.
Example 1
replace("Hello World", "l", "x")
Returns “Hexlo World”.
Example 2
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:
- string to evaluate:
|OFFER_A|OFFER_B
- provided by a profile attribute
#{ExperiencePlatform.myFieldGroup.profile.myOffers}
- String to be replaced:
|OFFER_A
- String replaced by:
''
- You need to add
\\
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}, '')
Journey Optimizer
- Journey Optimizer documentation
- What’s new?
- Get started
- Journeys
- Get started with journeys
- Create a journey
- Manage your journeys
- Browse & filter your journeys
- Profile entrance in journeys
- Supplemental identifier in event-triggered journeys
- Time zone management
- Send-Time optimization
- End your journey
- Copy a journey to another sandbox
- Troubleshoot your journey
- Troubleshoot inbound actions in journeys
- Integrate with Intelligent Services
- Activities
- Build expressions
- Use cases
- Campaigns
- Conflict management & prioritization
- Test & approve
- Communication channels
- Get started with communication channels
- Email channel
- In-app channel
- Push notification channel
- SMS / MMS / RCS channel
- Direct mail
- Web channel
- Code-based experience
- Content cards
- LINE
- Content management
- Landing pages
- Personalization
- Content templates
- Reusable content fragments
- Dynamic content
- Cross-solution use cases
- AI Assistant for content generation
- Multilingual content
- Content experiment
- Audiences, profiles & identity
- Reporting
- Get started with reports
- Live report
- All time report
- Custom journey reports
- Decision capabilities
- Get started with decision capabilities
- Decisioning
- Get started with Decisioning
- Decisioning guardrails & limitations
- API reference
- Manage decision items
- Configure item selection
- Create selection strategies
- Create decision policies
- Report on Decisioning
- Decisioning use case
- Decision management
- Get started with Decision management
- Create components
- Create rankings
- Create & manage offers
- Create & manage decisions
- Use batch decisioning
- Collect event data
- Leverage context data
- Create Decision Management reports
- Export your offer catalog
- API Reference
- Getting started
- Create & manage offers using APIs
- Deliver offers using APIs
- Data management
- Channel configuration
- Journey configuration
- Connect your systems and environments
- Access control
- Privacy