Referencing capture strings by using format string fields
Use the Format field on the Edit property behaviour tab to reference capture groups that you defined in the regex. Capture groups are referenced in their order of precedence.
About this task
A capture group is any regex that is enclosed within parenthesis. A capture group is referenced with an $n notation, where n is a group number that contains a regular expression (regex). You can define multiple capture groups.
For example, you have a payload with company and host name variables.
"company":"ibm", "hostname":"localhost.com"
"company":"ibm", "hostname":"johndoe.com"
You can customize the host name from the payload to display ibm.hostname.com by using capture groups.
Procedure
-
In the Expression field, enter the following regular expression:
"company":"(.*?)".*"hostname":"(.*?)"
- In the Format field, enter the capture group $1.$2 where $1 is the
value for the company variable (in this case ibm) and $2 is the value for the host name in the
payload. The following output is given: ibm.localhost.com ibm.johndoe.com