FAQ: How do I check for values between parentheses in a field name?

Q: I need to check whether there is 1 or more numbers between parentheses (parens) in a field, title. If the field value does have a parens, I want to append two fields to it, companyname and clientid.

A:
We'll use this example record:

{
"items": [
{
"title": "Test-Title (123)",
"companyname": "Acme",
"clientid": "10"
},
{
"title": "ExpandedTitle",
"companyname": "Acme",
"clientid": "5"
}
]
}

Check for an opening paren in the title, then for a digit following the ( paren.

{{#each items}}

{{#contains title (regexMatch title "\(\d+\)" 1 "g")}}{{title}}{{else}}{{title}} - {{companyname}} ({{clientid}}){{/contains}}

{{/each}}

This will result in:

Test-Title (123)
ExpandedTitle - Acme(5)

Here, #contains checks that the title field has a value, then the nested regexMatch handlebar function looks to see whether that value contains any parens. It looks for an open paren "(", a digit, then it looks for any extra digits "\d+\", then a close paren ")". If a paren does exist in the value and it contains numbers between the parens, the title is appended with -Acme(5). This is the companyname and clientid above.

If you are proficient in JavaScript, you can set up a preSave hook on the export step. Learn more about scripts.