Live data from Hacker News

Show HN: Regex Cheatsheet

ihateregex.io

11–20 of 135 posts

Re: Show HN: Regex Cheatsheet

#11
This is really cool!

2 points:

1. it fiddled with my back button which is a bit annoying

2. a better email sample is

    ^[^@]+@[^@]+\.[^@]+$ 
which removes the 2 ampersands problem.

Re: Show HN: Regex Cheatsheet

#12
post #11

This is really cool! 2 points: 1. it fiddled with my back button which is a bit annoying 2. a better email sample is ^[^@]+@[^@]+\.[^@]+$ which removes the 2 ampersands problem.

Thank you!

I think I know what's wrong with your back button. I will fix it.

And for the regex. will try it out and see if I can add it.

Re: Show HN: Regex Cheatsheet

#14
I use regex a lot but deliberately keep it simple.

One thing that confounded me often was positive and negative look-arounds. I always got the expressions mixed up, until I just put the expressions into a table like this...

              look-behind  |  look-ahead
    ------------------------------------
    positive    (?
It's not hard, but for whatever reason my brain had trouble remembering the usage because every time I looked it up, each of those expressions was nested in a paragraph of explanation, and I could not see the simple intuitive pattern.

Putting it into a simple visualization helps a lot.

Now, if I can find a similar mnemonic for backreferences !?

Re: Show HN: Regex Cheatsheet

#15
post #3

I'm loving the graphs which for the first time in years are giving me an idea of what an expression is actually doing. Just because the visualization is kept in a form that is easy to understand with a programming background but can also be translated to the expression itself in a straightforward manner.

Graphs for these really hammer home the point that regular expressions aren't magic. Parsers have so many abilities that when starting out, my expressions were horribly inefficient and missed many corner cases. Learning to graph them just like automata immediately made things easier.

When green devs are having trouble with regular expressions (and don't have a formal computer science background), I like to give them a crash course in DFAs.

Re: Show HN: Regex Cheatsheet

#16

I use regex a lot but deliberately keep it simple. One thing that confounded me often was positive and negative look-arounds. I always got the expressions mixed up, until I just put the expressions into a table like this... look-behind | look-ahead ------------------------------------ positive (? It's not hard, but for whatever reason my brain had trouble remembering the usage because every time I looked it up, each…

This is really intended for beginners. but I can confirm more content is coming soon <3

Re: Show HN: Regex Cheatsheet

#18
post #11

This is really cool! 2 points: 1. it fiddled with my back button which is a bit annoying 2. a better email sample is ^[^@]+@[^@]+\.[^@]+$ which removes the 2 ampersands problem.

You'll probably want to add \S to those character classes as well, or it matches "it's an @ sign. not an ampersand."

Re: Show HN: Regex Cheatsheet

#20
post #7

Plug for Verbal Expressions (no affiliation), which has an alternate way of compiling more human-readable regexes for a dozen languages: http://verbalexpressions.github.io/

I remember that library. A year after I made regexpbuilder https://www.npmjs.com/package/regexpbuilder that library suddenly appeared, and was basically a rip-off of the concept I appear to have created (there was no such other library before regexpbuilder), but is also fairly useless because it doesn't look like it could represent more than about 10% of the possible regular expressions. Yet there was no mention of my library at all in the readme of verbal expressions.
Post reply on HN