Splitting the output of OpenAI

I’ve been getting OpenAI to create multiple ChatGPT prompts in the same message.

How would I then split that output into individual elements that I can then email (or add to Google Sheets).

Eg. AI Output:



And I would like to end up with

Any ideas?

Welcome to the Make community!

Please provide an example output bundle of the module by running the scenario, then click the white speech bubble on the top-right of each module, save the bundle contents in your text editor as a bundle.json file, and upload it here into this discussion thread.

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

This will allow others to better assist you. Thanks!


Here’s the JSON.
openai.json (1.3 KB)

Welcome to the Make community!

You can use a Text Parser “Match Pattern” module with this regular expression pattern

PROMPT \d+:\n(?(?:.+(?:\n\n|$))+)

Regex test: https://regex101.com/r/DSqbUd/1

Important Info

  • :warning: Global match must be set to YES!



For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps!


Thanks for your help but hmm… doesn’t seem to be working for me. What am I doing wrong?


Looks like the second input is slightly different from the one your provided to me earlier.

You can do this in the field:


and update the regex to:

PROMPT \d+:\n(?<value>(?:.+(?:\n|$))+)

Thanks for your help. Now I get this.

Is there any way to make it more broad? It’s a ChatGPT output so sometimes it will have more lines (more line breaks) etc. The one point of consistency is the “PROMPT 1:” and then whatever text falls between that and the next prompt is the good stuff.

Sorry about this. Can you give me an example using this json which is more practical. I’ve tried the RegexOne expression builder and Regex101 and I am so deep out of my depth. Nothing I’ve tried works. Thank you for your help on this! I’d like each post separated into its own bundle.
openai-new.json (979 Bytes)

For additional consistency, perhaps you should include this in your prompt so that it’s easier to split the output:

Separate each prompt using five equal signs on a new line like this