DEV Community

Guilherme Samuel
Guilherme Samuel

Posted on • Originally published at guilhermefront.com

ChatGPT is a regex god

ChatGPT can give you statements that either:

  1. Sounds very truthful, but has something wrong with it
  2. Is surprisingly good and accurate

With Regex questions, it seems to weigh way more on the latter.

image

A few examples:

  1. Match a Reddit post URL
    Reddit post url ChatGPT response

  2. Match a Twitter reply
    Twitter reply ChatGPT response

  3. Match a document format from a country
    ChatGPT response

  4. Match any email address that ends with "gmail.com" and contains a plus sign (+) followed by any combination of alphanumeric characters before the @ symbol
    ChatGPT response

  5. Match any phone number in the format (XXX) XXX-XXXX where the first three digits cannot be 555
    ChatGPT response

Be careful, it's prone to mistakes, so it's always a good idea to test it on an app like https://regex101.com/

Overall, I feel like most of the generated regular expressions are already going to be good enough to save some valuable minutes of your life.

Top comments (0)