DEV Community

Geon George
Geon George

Posted on

I hated Regex so much that I made iHateRegex.io

In years of being a developer I never really spent the time to learn regular expressions. It always seemed like a hard nut to crack.

I used to spend so much time trying to find regular expressions for my use case.

now you have two problems

Enter iHateRegex.io

https://iHateRegex.io

I made a simple tool that will explain to you commonly used regular expressions work.

It is a simple tool that will show a visual graph as well as matches and highlighting for code.

Hope you like the tool :D

Tech

Public Repo: https://github.com/geongeorge/i-hate-regex

The application is built using:

Update

  • Thank you for all the love and support guys πŸ’“ Posting this has given me enough motivation to work on this more.
  • The application is just an MVP right now. With the support of everyone, I can make this into a great project for beginners.
  • I'm also working on tutorial pages to get started on regex. here's a sample

Producthunt launch

I just launched iHateRegex on Producthunt 😺

πŸ‘‰πŸ‘‰
https://www.producthunt.com/posts/i-hate-regex

Latest comments (89)

Collapse
 
alvechy profile image
Alex Vechy

Wow, this is great. Thanks man!

Collapse
 
vbelolapotkov profile image
Vasily Belolapotkov

This is awesome @geongeorge ! Thank you!

Collapse
 
geongeorge profile image
Geon George

Don't forget to bookmark :P

Collapse
 
maartyl profile image
maartyl

I like regex. I hate when people invent weird custom 'subsets' of regexp, instead of using this thing that works well. (albeit, I agree: it's not very readable. Free space regex with comments solves that, though.)

Collapse
 
petermortensen profile image
Peter Mortensen • Edited

Regular expressions are extremely useful in (ad hoc) scripts and sometimes in search-replace operations in text editors (also for pure search to become more specific (fewer false positives)).

Typically one-off scripts to extract and output information from line-oriented input (even HTML). They don't need to be robust and are (usually) not maintained. They get the job done quickly and efficiently.

Collapse
 
tomholden1 profile image
Tom Holden

Nice job - love it!

Collapse
 
kovirobi profile image
Kovacsics Robert

One of the things about regexes is that they are (generally) not regular in two senses of the word:

1) they have different syntax for perl/PCRE, Python, Emacs, Vim, ...;
2) they are not regular in the linguistic/CompSci sense of the "regular languages", and even when they are, backtracking parsers are (almost always) used on them and this can lead to denial-of-service bugs :(

Collapse
 
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

Is the site down? I can't reach it.

Collapse
 
geongeorge profile image
Geon George

Yes, it was for a couple of minutes. It's back online :)
Don't know what happened

Collapse
 
fractalsystems profile image
Michael Lawler

Still down/Down again for me.

Thread Thread
 
geongeorge profile image
Geon George

Did a huge update and had some issue with ssl.
I guess it's fine now :)

Collapse
 
bitmaybewise profile image
Hercules Lemke Merscher

Awesome!

Collapse
 
mikeschinkel profile image
Mike Schinkel • Edited

I have been a programmer for over a quarter of a century. And I used to think that I would never "get" regular expressions. Then one day about 6 or 7 years ago I realized I could write regular expressions correct about 80% of the time, after which it occurred to me that I now "get" regex. What changed?

I started using PhpStorm (or any JetBrain's IDE) and forced myself to use regular expressions to do search and replace. Because of how their UI works β€” itΒ includes a preview of the result for each occurence when it asks if okay to replace β€”Β it basically trained me to grok regex.

So, trying to learn regular expressions only when you need to use one in your code will, if you are like me, leave you forever unable to become one with regex. But if you would like to learn the 20% of regex like the back of your hand that you'll use 80% of the time, grabbing a JetBrain's IDE (or maybe some other IDEs or text editors) and forcing yourself to use regex on almost every search is really all it takes.

#jmtcw

Collapse
 
geongeorge profile image
Geon George

Thanks for sharing the story Although I didn't use any special ide other than vscode, building ihateregex.io made me understand a lot of it. I can build my own expressions now.

Collapse
 
hasii2011 profile image
Humberto A Sanchez II

oooohhhh, I will defintely take a look at this. I hate regex also and the visuals you are providing will definitely help me debug my expressions

Collapse
 
sganz profile image
Sandy Ganz

Awesome work!

I don't particularly hate Regex's but I hate getting them right!

I have used this online tool (No connections to the site) regex101.com/ for a few years as something to test and help at least validate the cRaZyNeSs that sometimes happen when you "over do it" with Regex's

Keep up the great work!

Sandy

Collapse
 
richardhendricks profile image
Richard Hendricks

I love regex101.com for understanding some else's regex and breaking it down into component parts. Really handy for that.

Collapse
 
rohitmsasi profile image
Rohit

Hey Geon, cool project. Pretty sure it'll be handy to many.

Even the other day at work we were talking about how clueless we are about regex.
I'll do share it with them.

Collapse
 
geongeorge profile image
Geon George

Thank you. that'd be awesome

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Delightful tool. Bookmarking!

I also hate regex, so much that I'm helping design an expression parser that addressees many of its flaws. This new parser won't replace regex β€” trying to be everything to everyone is how it came to be so annoyingly esoteric to begin with β€” but it'll hopefully be better than what we have for a number of common cases.

Collapse
 
geongeorge profile image
Geon George • Edited

Thank you.
Your parser would be amazing. If it plugs into javascript I really would love to try it out.

Collapse
 
codemouse92 profile image
Jason C. McDonald

I'm implementing it for our C++ game engine, so this implementation won't be Javascript compatible. That said, both the code and the specification will be open source, so there's nothing stopping you (or anyone else) from implementing it elsewhere.

Thread Thread
 
geongeorge profile image
Geon George

is it already under construction? I'd love to see the repo

Thread Thread
 
codemouse92 profile image
Jason C. McDonald

We're fairly early in the implementation stage β€” the code is currently under a serious breaking refactor β€” but you certainly check it out. The project page is here, and you can follow our development on Phabricator.

Thread Thread
 
geongeorge profile image
Geon George

This looks cool

Thread Thread
 
geongeorge profile image
Geon George

I really wanted a parser built like regex101 for my tool. Really don't know where to start
github.com/geongeorge/i-hate-regex

Collapse
 
ryansmith profile image
Ryan Smith

Awesome, having the diagrams and cheatsheet right there is very helpful. It will be much easier to figure out how to customize it and learn something along the way. Great work!

Collapse
 
geongeorge profile image
Geon George

Thank you. More features are coming as we speak. Do check us out in GitHub: github.com/geongeorge/i-hate-regex

 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

@bpedroza
You have a good point, which will allow me to refine my position.

I think that we should stop over focusing on the HOW you did the pattern matching part (oh see, a nice regex! let me make it even better) and focus more on the WHAT it's supposed to do and WHY it's important.

Having the unit tests for the regex allows to reframe the question this way.
Then it's an implementation detail whether you use a regex or a parsing library or whatever, and I am fine with all of those solutions.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.