Live data from Hacker News

Regexper: Beautiful regexp visualizations

regexper.com

91–100 of 132 posts

Re: Regexper: Beautiful regexp visualizations

#91
post #76
post #64

Earlier quoted context omitted.

This is a good point. Also mentioning which flavour of regexp is supported would be nice.

The input bar says Javascript style before you start typing something in..

Since I do mostly back-end stuff, I'm quite bad at Javascript regexes off the top of my head :)

Re: Regexper: Beautiful regexp visualizations

#92
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]+(?:(?:…

BTW, using this regex to validate email is a bad idea. For one thing, it doesn't cover RFC5322. The only right way to do it, as far as I am concerned, is state machine code that evaluates the address character by character as well as DNS.

It is probably acceptable in most cases to just use a trivial regex to match the most likely 99.9% of addresses. 'something@something.something', maybe checking that last something for some sanity.

I mean, obviously unless you are writing an MTA or whatever.

Re: Regexper: Beautiful regexp visualizations

#93
post #83

Earlier quoted context omitted.

As an aside. I quit using regex to validate email addresses a while ago. Part of it is that a regex that large is simply incomprehensible and very difficult to maintain and fix if something is broken. The best solution, in my opinion, is a state machine based analyzer that checks the email address character-by-character and confirms compliance with RFC5322. This would also include checking DNS for MX records (which m…

No, stop validating emails. Not only it's error prone and will frustrate legit users but it utterly pointless.

The thing is, email input validation is only one use case for regex and emails. Here's a more sinister one: you want to build a web scraper looking for emails to add to your spam list. Put a bit more generically, you need a script that can import email addresses from a broad and unknown host of formats, and it is impractical to condition the data beforehand.

I agree that the value derived from email validation for something like a new account registration is almost nil. Just do something like an email verification round trip, which not only validates the email could be real, but also provides assurance that the user has control of the email address used.

Note: My last name is O'Kelley, which is a bit of a pain when it comes to poorly designed computer services. Some sites will strip the ' and others will escape it so that I become Mr. O\'Kelley. The worst I've seen is that my school used my complete last name in my email address, so most sign up forms refuse to even try to accept it, even though it is a valid email address. It can be a pain if I need to use my .edu address for academic discounts or verification.

Re: Regexper: Beautiful regexp visualizations

#94
post #54

Earlier quoted context omitted.

No, it's called a finite state machine ;)

The FSM is the model, the Railroad Diagram is the view, to borrow terms.

Well, as long as we're picking nits, an FSM accepts only regular languages, while a rail road diagram accepts context-free languages[1]. So a railroad diagram isn't really the "view" for an FSM. A state-diagram or state-transition table is (although the whole MVC analogy is itself kind of weird. Where's the controller?).

[1] http://en.wikipedia.org/wiki/Syntax_diagram

Re: Regexper: Beautiful regexp visualizations

#95

Hello, I'm the creator of this (trevmex is one of my co-workers). I just want to thank everyone for the feedback so far, I am looking into the issues that have been brought up (they'll have to wait until this evening to be fixed though...I have a day job).

You should contact owners of regexp snippets websites like regexlib.com and allow them to embed your graphs next to their regexp.

Re: Regexper: Beautiful regexp visualizations

#96
post #34

but it doesn't show what is matched - as in a example matched string - which is the most important thing also how do you put in the case insensitive flag?

I think this would be quite valuable -- provide a second input for sample text and highlight the path taken. Bonus points for figuring out a way to handle multiple sample inputs, showing capturing group output, etc.

Extending this idea, a regex (code)coverage tool would be great...

Re: Regexper: Beautiful regexp visualizations

#97

Hello, I'm the creator of this (trevmex is one of my co-workers). I just want to thank everyone for the feedback so far, I am looking into the issues that have been brought up (they'll have to wait until this evening to be fixed though...I have a day job).

Great work, thanks for making it.

Re: Regexper: Beautiful regexp visualizations

#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.

Re: Regexper: Beautiful regexp visualizations

#99
post #94

Earlier quoted context omitted.

The FSM is the model, the Railroad Diagram is the view, to borrow terms.

Well, as long as we're picking nits, an FSM accepts only regular languages, while a rail road diagram accepts context-free languages[1]. So a railroad diagram isn't really the "view" for an FSM. A state-diagram or state-transition table is (although the whole MVC analogy is itself kind of weird. Where's the controller?). [1] http://en.wikipedia.org/wiki/Syntax_diagram

>Where's the controller?

The MV* family of patterns seems to be okay without the notion of a controller.

Re: Regexper: Beautiful regexp visualizations

#100
post #57

Hello, I'm the creator of this (trevmex is one of my co-workers). I just want to thank everyone for the feedback so far, I am looking into the issues that have been brought up (they'll have to wait until this evening to be fixed though...I have a day job).

You should build a tool that is the inverse of this. Let people build regular expressions by creating the visual diagram (some sort of click and drag GUI).

similar: http://txt2re.com/
Post reply on HN