Skip to content
Documentation
Updated 3 minutes to read
Markdown

The replaceregex Formula function returns the content with every match of a regular expression replaced by newValue.

Extract the ERP reference with regex and strip its prefix with replaceregex, animated walkthrough (7.12)
Animated walkthrough: on the Order Entry XML of the Order-to-Cash demo, regex first finds the ERP reference ERP-2025-10005; wrapped in replaceregex, the ERP-2025- prefix is replaced by an empty string and 10005 remains.

replaceregex('pattern', 'newValue', content)
Parameter Required Description
'pattern' Yes A .NET regular expression. Write backslashes once, for example '\d+'; see the Formula language rules.
'newValue' Yes The text to substitute for each match. $1, $2, and so on insert the capturing groups of the match (Example 4).
content Yes The text to change: body, context, or the result of another function, such as xPath2.

The content with all matches replaced. Content without a match is returned unchanged. When the content holds several values, the replacement runs on each value: replaceregex('a', 'b', …) on the two values aa and ca returns bb and cb.

<ProjectNumber>1401518</ProjectNumber>
replaceregex('[0-9]', 'X', body)
<ProjectNumber>XXXXXXX</ProjectNumber>

Test Expression tab: replaceregex with the digit class 0-9 and X on the body turns ProjectNumber 1401518 into XXXXXXX (7.12)
Each digit is a separate match, so all seven digits are replaced one by one.

<Action>DELETE</Action>
replaceregex('DELETE', 'UPDATE', body)
<Action>UPDATE</Action>

Test Expression tab: replaceregex('DELETE', 'UPDATE', body) changes the Action element from DELETE to UPDATE (7.12)
A pattern without special characters matches the word as is; replace gives the same result without regular expression syntax.

<Company>400</Company>
replaceregex('<Company>[0-9]+</Company>', '<Company>XXX</Company>', body)
<Company>XXX</Company>

Test Expression tab: replaceregex masks the Company value 400 as XXX and keeps the element tags (7.12)
The pattern matches the whole element, so newValue writes the tags back around the mask.

Example 4: Build one value per record with capturing groups

Section titled “Example 4: Build one value per record with capturing groups”

xPath2 returns each inner TypedPollingResultSet0 record. The pattern captures Company, Activity, and Action, and '$1|$2|$3' replaces the whole record with the three captured values.

<TypedPolling>
<TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>1401518</ProjectNumber>
<Company>400</Company>
<Activity>1000</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>1401518</ProjectNumber>
<Company>400</Company>
<Activity>1001</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>4831351</ProjectNumber>
<Company>355</Company>
<Activity>1063</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>9233120</ProjectNumber>
<Company>700</Company>
<Activity>3400</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
<TypedPollingResultSet0>
<ProjectNumber>9402000</ProjectNumber>
<Company>734</Company>
<Activity>5104</Activity>
<Version>20250301060028</Version>
<Action>DELETE</Action>
</TypedPollingResultSet0>
</TypedPollingResultSet0>
</TypedPolling>
replaceregex('.+<Company>(.+)</Company>.+<Activity>(.+)</Activity>.+<Action>(.+)</Action>','$1|$2|$3',xPath2('/TypedPolling/TypedPollingResultSet0/TypedPollingResultSet0',body))
400|1000|DELETE
400|1001|DELETE
355|1063|DELETE
700|3400|DELETE
734|5104|DELETE

Test Expression tab: replaceregex with capturing groups on xPath2 records returns five values such as 400|1000|DELETE (7.12)
Five records give five unique values, each built from the Company, Activity, and Action of one record.

  • To replace plain text without regular expression syntax, use replace; it treats every character literally.
  • To extract matches instead of replacing them, use regex or regexGroup.

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...