Live data from Hacker News

Regexper: Beautiful regexp visualizations

regexper.com

121–130 of 132 posts

Re: Regexper: Beautiful regexp visualizations

#121
post #98
post #73

it breaks with this: (?:(?:\r\n)?[ \t]) (?:(?:(?:[^() @,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t] )+|\Z|(?=[\["() @,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t])) "(?:(?: \r\n)?[ \t]) )(?:\.(?:(?:\r\n)?[ \t]) (?:[^() @,;:\\".\[\] \000-\031]+(?:(?:( ?:\r\n)?[ \t])+|\Z|(?=[\["() @,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t])) "(?:(?:\r\n)?[ \t]) )) @(?:(?:\r\n)?[ \t]) (?:[^() @,;:\\".\[\] \000-\0 31]+(?:(?:…

To anyone that sees this email validation regex, DO NOT USE IT. Hope that was clear, if not obvious. Use something like `^([^\s]*)@([^\s]*\.[^\s]*)$` which will do most of the work for you, then check second group for common domain typos, and what have you.

> then check second group for common domain typos, and what have you.

You can use something like Mailcheck.js [0] for that client-side; it'll help weed out a lot of domain typos.

[0] - https://github.com/kicksend/mailcheck

Re: Regexper: Beautiful regexp visualizations

#123
post #98

Earlier quoted context omitted.

To anyone that sees this email validation regex, DO NOT USE IT. Hope that was clear, if not obvious. Use something like `^([^\s]*)@([^\s]*\.[^\s]*)$` which will do most of the work for you, then check second group for common domain typos, and what have you.

>Use something like `^([^\s]*)@([^\s]*\.[^\s]*)$` which will do most of the work for you I don't understand. How does this expression do anything even remotely close to email validation? For example, how does it tell you that: These are valid: test@nasa.gov ~~~~@nasa.gov joe+sometext@nasa.gov test@bbc.co.uk and that: These are NOT valid test@example.com (no MX RR) test@-nasa.gov test"@nasa.gov test@nasa.gov- test tes…

It's a good approach because it doesn't filter out grammatically correct e-mails while blocking the blatantly false.

About the invalid cases, who cares? It's not a problem, you must send an e-mail to check for correctness either way:

your user may

* wrongly type his e-mail e.g. bil.gates@microsoft.com

* write on purpose a valid e-mail of another person e.g. yourbestenemy@gmail.com

* write a grammatically valid but nonexistent address

* forget how to access his own e-mail address

You must always send a mail to confirm his validity, so if you have some false positives there is no harm, and it's faster to validate too.

Re: Regexper: Beautiful regexp visualizations

#124
post #117

Earlier quoted context omitted.

>Use something like `^([^\s]*)@([^\s]*\.[^\s]*)$` which will do most of the work for you I don't understand. How does this expression do anything even remotely close to email validation? For example, how does it tell you that: These are valid: test@nasa.gov ~~~~@nasa.gov joe+sometext@nasa.gov test@bbc.co.uk and that: These are NOT valid test@example.com (no MX RR) test@-nasa.gov test"@nasa.gov test@nasa.gov- test tes…

Honestly I don't understand why people get all flustered over email validation, I would probably use something along the lines of this just to check that the email address is along the lines of name@domain.com, obviously this could do with a little tweaking. The best way to validate an email address is to send an email to whatever address is supplied to you, if it is a true email address the user will receive an emai…

> Honestly I don't understand why people get all flustered over email validation

Multiple reasons, and, yes, context is important.

Landing Page: You have one, and ONLY ONE, opportunity to capture a potential new customer's contact info. If they make a mistake entering their email and you didn't catch it you'll loose them forever. You can't send an email to let them know they entered two periods by mistake, can you? They are gone and you screwed-up.

Every single potential customer is sacred. Thou shalt not loose them by being careless.

Forum signup: In general terms, if someone is visiting a forum it probably means that they want to sign-up. In this case, it is OK to make them enter their address twice, make sure they match and send them a confirmation email. They'll probably try to log-on later on and discover something went wrong and re-register.

While I said "that's OK", I also think it is bad form not to at least do enough validation of all input data, including email, to catch innocent mistakes. I think people who are against email validation might have that position because they don't understand it or gat bitten by a crappy regex expression and that is that.

Now your forum sign-up user is angry because they have to enter all of their information again and go through the process one more time. Who knows, they might make a mistake once again. While I don't have any data to back this up I would venture to guess that the drop-off rate for making a visitor enter all of their data multiple times is significant.

Payment Confirmation: Must check as much as you can.

From my vantage point taking ANY action that might loose or annoy a visitor is simply --to be kind-- programming. There's no excuse for that in my book.

Re: Regexper: Beautiful regexp visualizations

#125
Unfortunately it seems to be broken now, but reAnimator was an awesome regex visualization tool (http://osteele.com/tools/reanimator/). It let you enter a regex and would display the state machine similar to this, but then it would also let you enter a string and it would animate the progress of the string matching (or not) against the state machine as you enter each character.

Re: Regexper: Beautiful regexp visualizations

#126

Earlier quoted context omitted.

>Use something like `^([^\s]*)@([^\s]*\.[^\s]*)$` which will do most of the work for you I don't understand. How does this expression do anything even remotely close to email validation? For example, how does it tell you that: These are valid: test@nasa.gov ~~~~@nasa.gov joe+sometext@nasa.gov test@bbc.co.uk and that: These are NOT valid test@example.com (no MX RR) test@-nasa.gov test"@nasa.gov test@nasa.gov- test tes…

It's a good approach because it doesn't filter out grammatically correct e-mails while blocking the blatantly false. About the invalid cases, who cares? It's not a problem, you must send an e-mail to check for correctness either way: your user may * wrongly type his e-mail e.g. bil.gates@microsoft.com * write on purpose a valid e-mail of another person e.g. yourbestenemy@gmail.com * write a grammatically valid but no…

> It's a good approach because it doesn't filter out grammatically correct e-mails while blocking the blatantly false.

Sorry, that's not a good reason to use this. If you use the correct approach you will NOT filter out syntactically correct emails and you WILL catch all invalid addresses that can be detected syntactically.

It just isn't a good idea to use this expression in place of the RFC822 expression. And, keep in mind, I am not a fan of the RFC822 expression.

With regards to your other scenarios, please read my reply to "rawb92" here:

http://news.ycombinator.com/item?id=5003032

In a nutshell, if someone enters a malformed email address by mistake and you don't catch it, it's game over. What are you going to do? Send them an email?

The spammers and tricksters will always exist. You'll have to decide how to deal with them yourself. In other words, stuff like someone attempting to sign-up their buddy to a porn site. That's got nothing to do with email validity, that's a matter of identification, and, yes, in that case the first line of defense is to send out a confirmation email.

Re: Regexper: Beautiful regexp visualizations

#127

Earlier quoted context omitted.

You could base64 it first.

With an effective maximum URL length of 2000 characters, you'd be stuck with a regex limit of around 1300 characters once you take into account the overhead of base64 encoding.

I'm pretty sure this webapp isn't capable of rendering any regex with 1300 character anyway (or if it could, the client couldn't handle that much SVG). I don't expect URL length would be the limiting factor here.

Re: Regexper: Beautiful regexp visualizations

#128

Really cool. Any chance you could add an export-as- option?

Well the image already is a SVG element. But it's dynamically generated so you need a slight bit of trickery to grab it, enter this in your JS console: (tested with Opera and Chrome)

    document.location.href = 'data:image/svg+xml,'+encodeURIComponent(document.getElementById('paper-container').innerHTML)
it'll open just that element as a SVG document, where you can save it with ctrl-S.

I'd like to have used window.open instead of document.location so it wouldn't replace the RegExper tab, but that gets caught in my browsers' pop-up blockers :) Inserting it as a regular link in the original document would've been the best solution, in a pinch, I am offering this quick hack :)

Also, poking at this puzzle, I just noticed the badass colour green he's using for the diagrams and header.

Re: Regexper: Beautiful regexp visualizations

#129
post #35

Neither beautiful nor a visualization really. For the uninitiated, there's an isomorphic relationship between regular expressions (not PCREs which are way more complicated) and finite state automata proving that if you have a regexp you can generate a FSA for it, and visa versa. What we have here is a system that generates a graph of the finite state automaton for any given regular expression. Neat project, misleadin…

This type of useless comment is why I tend to avoid HN for periods at a time. Congrats, you've shown the world you know what "isomorphic" and "FSA" means, but did you initially bring anything constructive? No. You had to edit in things barely constructive because your impulse was to tear down rather than build up. > Neither beautiful nor a visualization really. This is the least helpful thing I can imagine. "Here's a…

> This type of useless comment is why I tend to avoid HN for periods at a time.

There's useless pedants like this all over the Internet. You should probably wear a hat.

I'd agree if this were the top two comments without many disagreeing replies or down-votes.

I see this comment in down-voted grey, somewhere way down the page and assume a lack of social skills, bad-morning-before-coffee-grumps.

Or simply Internet Asshat Background Radiation, it's everywhere. Legends say you can trace its echos back to the First Flame from which the Internet was born.

Re: Regexper: Beautiful regexp visualizations

#130
post #35

Earlier quoted context omitted.

This type of useless comment is why I tend to avoid HN for periods at a time. Congrats, you've shown the world you know what "isomorphic" and "FSA" means, but did you initially bring anything constructive? No. You had to edit in things barely constructive because your impulse was to tear down rather than build up. > Neither beautiful nor a visualization really. This is the least helpful thing I can imagine. "Here's a…

> This type of useless comment is why I tend to avoid HN for periods at a time. There's useless pedants like this all over the Internet. You should probably wear a hat. I'd agree if this were the top two comments without many disagreeing replies or down-votes. I see this comment in down-voted grey, somewhere way down the page and assume a lack of social skills, bad-morning-before-coffee-grumps. Or simply Internet Ass…

It wasn't grey when I commented. I wouldn't take the time to get on a soapbox if the community had already buried it.
Post reply on HN