Skip to content
Documentation
Updated 2 minutes to read
Markdown

The regexGroup Formula function returns the value of a capturing group of a regular expression, instead of the whole match that regex returns.

Return only the SKU of every order line with regexGroup instead of regex, animated walkthrough (7.12)
Animated walkthrough: on the Order Entry XML of order ORD-10011 in the Order-to-Cash demo, the expression is limited to its Message Type and tested. regex returns each whole <SKU>…</SKU> element, tags included; regexGroup with group '1' returns only the three SKU values.

regexGroup('expression', 'groups', content)
Parameter Required Description
'expression' Yes A .NET regular expression with at least one capturing group ( ), in single quotes. Backslashes are written once ('\d+').
'groups' Yes The number of the capturing group to return, such as '1' for the first group. Quoted '1' and unquoted 1 both work.
content Yes The text to search: body, context, or the result of another function (see Formula language rules).

The value of the selected group for every match, one value each; duplicates are collapsed. When a group repeats inside one match (for example (…){4}), the value from its last repetition is returned. When nothing matches, nothing is returned.

Example 1: Read the order IDs from the body

Section titled “Example 1: Read the order IDs from the body”
ID=123,CUSTOMER=1
ID=456,CUSTOMER=2
regexGroup('ID=(\d+)', '1', body)
123
456

Formula regexGroup expression returning two ID values from a text message body in the Test Expression tab (7.12)
Group 1 captures only the digits after ID=, so the ID= prefix is not part of the result.

Example 2: Read the fourth field of a pipe-delimited context value

Section titled “Example 2: Read the fourth field of a pipe-delimited context value”

The Message Context key OrderRecord holds a pipe-delimited order record:

Key Value
OrderRecord ORD|101|ExampleCompany1|456|Company Name ACME |Dieselgate valley 1|123 45|Flameburg|
regexGroup('^(?:(.*?)\|){4}', 1, context('OrderRecord'))
456

Formula regexGroup expression returning the fourth pipe-delimited field from the OrderRecord context property in the Message Context tab (7.12)
(?:(.*?)\|){4} repeats four times from the start of the value; group 1 keeps the last repetition, the fourth field (counted from 1), 456.

  • \| matches a literal pipe; an unescaped | means "or" in a regular expression.
  • To return the whole match instead of a group, use regex.
  • For one pattern on the body, the RegEx with capturing groups plugin returns groups without a formula, and accepts several group numbers or names. See Choose a plugin.

...

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...