Photo by — @rldgs

English to Regex thanks to GPT-3?

Perhaps you can spend less time searching for regular expressions online — check out this demo

This is a short article about one possible feature resulting from the new GPT-3 by OpenAI based on a prototype-demo posted on Twitter. I realise not everyone knows what ‘regex’ is, so I thought I would explain. A “regular expression” (regex) is a sequence of characters that define a search pattern. Usually such patterns are used by string-searching algorithms for “find” or “find and replace” operations on strings, or for input validation. It is a technique developed in theoretical computer science and formal language theory.

I wrote a short piece on GPT-3 yesterday, however to sum up, according to a journalist in MIT Technology Review: “GPT-3 is the most powerful language model ever.” That may be an over-statement. However, the model has 175 billion parameters and can generate almost any kind of text. Although, it has severe limitations, such as occasionally spewing hateful racist or sexist language, as it is partly trained on large text structures on the web.

Following this I discovered a tweet from Parthi Loganathan, that I immediately checked out and retweeted.

He created a short website where you can sign up for early access.

On this website he made a short video, and I turned it into a GIF to fit on Medium.

The idea is that you can:

  1. Described the regex you want.
  2. Provide an example of a string that will match.
  3. Generate the regex.

Since I am currently looking at an analysis of text I thought this was clever.

It is not likely I will be able to use this any time soon.

Additionally, it must be said that a regex generator based on giving descriptions to automatically generate regex does not mean one can neglect learning about regular expressions.

You already have RegExr: “Regular expression tester with syntax highlighting, PHP / PCRE & JS Support, contextual help, cheat sheet, reference, and searchable community patterns.”

Then there is Regex101: “Online regex tester, debugger with highlighting for PHP, PCRE, Python, Golang and JavaScript.”

You can also find a lot of information on Regular Expression.

As well as a practical cheat sheet!

As well as specifically for Python:

So, I hope you find this article helpful, and the prospect of descriptions to generate RegEx too.

This is #500daysofAI and you are reading article 417. I am writing one new article about or related to artificial intelligence every day for 500 days.

AI Policy and Ethics at www.nora.ai. Student at University of Copenhagen MSc in Social Data Science. All views are my own. twitter.com/AlexMoltzau

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store