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. You can learn more about my AI Training and AI Consultancy services here.

 

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,$A$4) 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,$A$4

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 OpenAI.com

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 the version of Regex (e.g. RE2) you wish to use in Cell A4. 

5) 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.

6) Add the function =GETREGEX(B2,$A$4 to cell C2

7) 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.

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

9) 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.

Notes:

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.

Check out some of my other scripts and tools for marketers using OpenAI’s technology.