How to parse content within parentheses in Zapier workflows

I need assistance with extracting specific pieces of information from API outputs in my Zapier workflow.

I receive messages from an API like “order processed with discount code (XYZ12345) and some extra info”. My goal is to isolate and capture just the code inside the parentheses to forward it to another application seamlessly.

The codes can vary significantly; sometimes they’re brief (A1), while at other times they’re longer strings (SUMMER2024SALE). The format changes frequently.

Can anyone suggest the best method in Zapier to extract the text enclosed in these parentheses, no matter what the code’s structure looks like? I’ve been facing challenges with this and would appreciate any advice on effectively managing this variable information extraction.

Try using Split Text in Formatter by Zapier instead. Split on the opening parenthesis ‘(’ first, grab the second part, then split again on the closing parenthesis ‘)’. You’ll get what’s between the parentheses without touching regex. I like this better for complex workflows - regex can be a pain to debug later. Plus it’s way easier for teammates to understand and modify down the road.

i’d use a code step in zapier for this. just drop in some javascript like text.match(/\(([^)]+)\)/)[1] - way more flexible than the formatter and handles weird edge cases better. always works for me and u don’t need multiple steps like u would with splitting.

I encountered a similar issue while setting up my own Zap. To extract text from parentheses, you can utilize the Formatter by Zapier’s ‘Text’ option and select ‘Extract Pattern’. The regex to use is ‘(([^)]+))’ which effectively captures any content nestled within the parentheses. This method has proven reliable for various formats of codes I’ve dealt with, ensuring that the extracted values are clean and ready for subsequent actions in your workflow. It’s a straightforward approach that simplifies the data management process.