AutoRegex: An AI tool that can write your Regex | Aakash Bhardwaj

Post

AutoRegex: An AI tool that can write your Regex

Hi,

Hope you are having a terrific day.

As a developer, one of the most excruciating things that I have to do from time to time is writing Regular Expressions. The amount of time that I have spent on just writing Regex is insane. I was working on a project recently where I had to write some Regex and I wondered if there was an AI tool to help me. To my surprise, there was. One of those tools is called AutoRegex.xyz

media

Note:

Now, before using any AI tool, I personally believe that we should know what we are doing or at least the gist of the thing that we are trying to find the solution for. For instance, in my case, I think it's important to know the basics of Regex. AI tools are amazing but let us not forget our roots.

About AutoRegex:

AutoRegex is an innovative website providing an AI-driven Regex automation service. It is easy to use with the ability to generate Regex, as well as convert it to plain English. It is a useful tool that saves you the effort of creating and understanding complicated Regex. Let's try to feed this tool with a couple of examples.

Example 1:

I asked AutoRegex to generate a Regex for a username that consists of alphanumeric characters along with ., _, and * symbols.

A simple test case. But back in the day, it took me 20 minutes to tweak the Regex. But with this tool, I was able to get the answer in a matter of seconds.

Response: `^[a-zA-Z0-9._*]+$`

Example 2:

I asked AutoRegex to generate a Regex that matches any given time in AM and PM.

Response: /(?:(1[0-2]|0?[1-9]):([0-5][0-9]) ([AaPp][Mm]))/

Seemed right. I had to verify it and it was indeed correct.

Example 3:

I asked AutoRegex to generate a Regex that matches any URL.

Response: ^(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$

Again, I had to verify. And to my surprise, it was an incorrect regular expression. I tried to generate another response and this time, the response was this.

Response: `^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$`

Regex was correct this time but it didn't cover all the test cases for a URL.

Conclusion:

AutoRegex is a great tool to have in your arsenal but it is also capable of making many mistakes. So always verify the output of the Regex that you are trying to generate before using it in your code. I am sure it will be even more efficient with time. For many simple cases, it is surely a great tool and will save your development time.