Convert English to Regex in Google Sheets with GPT3

24/02/2022, SEO

Convert English to Regex in Google Sheets with GPT3

Watch this (four-minute) video to learn how to convert English to Regex using GPT3.

Do you struggle with Regex? 

Download a copy of my Google Sheet and script to put an end to your tears.

Enter an English description of the filter required in any cell and receive a response in correctly-formatted Regex.  

The script uses OpenAI’s GPT3 machine learning model to convert standard English statements into valid Regex. 

You don’t need to be especially precise with your description. Just make sure any rational human could reasonably understand it.    


What is GPT3?

GPT3 is a pre-trained machine learning language prediction model capable of classifying words and phrases into pre-determined categories.

While this may sound like it belongs to the domain of AI experts, GPT3 is easy to use and can be applied via a simple API request.


Free English>Regex Converter in Google Sheets 

I have created a script in Google Sheets to help you convert standard English to Regex statements. Describe the Regex statement you need, enter the function =GETREGEX(XX) into any cell and allow GPT3 to work its magic. Remember to replace the XX with the cell containing your English description. e.g. =GETREGEX(B2) . 

Please watch the video above to see it in action and download a copy of the script here.


How can I use it?

1) The first step is to register a free account at

Upon registration, you will be given $18 worth of free API credits.

Once registered, grab a copy of your secret API key and save it on your device.


2) Download a copy of my free Google Sheet and script designed to make this process as easy as possible without having to understand or write any code.

3) Enter your API Key from Step 1 in cell A2 of the Google sheet.

4) Enter a description of your required filter in English to cell B2, e.g. Contains the words “dog” or “cat”

The words you use in this prompt will impact the quality of the output, so make sure that you explain your requirements clearly.

5) Add the function =GETREGEX(B2) to cell C2

6) Add any additional rows as required in column B and copy the formula down to all adjacent rows in column C.

You may be asked to grant the script permission to run if this is your first attempt.

7) After a short delay, you should receive valid Regex statements based on the English description you provided.

8) Once the results are received, click on the “Save Values” link in the main menu. This will convert your formulas to plain text values and prevent the API from being called whenever you modify a row or refresh the sheet.


Take a look at the script behind this function by selecting Extensions > Apps Script from the main menu. 

Please watch the (4 mins) video above to see the script in action and receive visual and verbal instructions.

Please let me know how you get on.



Version 1 of this script released on 24/02/2022 made use of OpenAI’s ‘Codex’ engine. I was unaware at that time that the Codex engine was still in private beta. As a result, some users may have experienced an error, “Engine not found” while using V1 of this script. Please accept my sincere apologies.

On 25/02/2022, I updated the script and all links in this post to Version 2 to use the Davinci engine which is not in private beta. When tested, I found the results produced by the Davinci engine to be no less accurate than using the Codex engine.

If you experienced any issues with V1 of the script, please download a copy of V2 here. This will hopefully resolve any issues.

Alternatively, if you prefer to use V1 of the script, you can apply to join the Codex beta. When I did so, I was granted permission almost immediately. You may find that you get slightly better responses uses Codex although I have not noticed any difference when testing.