News for hackers. Stuff that matters.
Re:Regexper – Regular expressions visualizer by ken on Tuesday January 30, 2018 @12:44PM (#16267219)
It's always neat to see where one's ideas go! AFAIK, I was the first person to create dynamic railroad diagrams for regular expressions (maybe 12 or 13 years ago). I got the idea from json.org, which I think was Douglas Crockford's brainchild.

My initial implementation was strfriend.com (in Lisp: well under 1,000 lines, including views), and I think its main claim to fame was that Jeff Atwood made fun of it on Twitter. (I was truly clueless at promoting myself back then. Not only did I not have a Twitter account, but it didn't occur to me to submit it to HN.)

Every so often, I toy around with the idea of making it into a proper local/native application -- maybe someday. In the meantime, my obsession with regular expressions lives on in my current application (see bio) where I parse and rewrite the user's entered regex syntax (ICU) into whatever regex syntax the backend requires. I don't know of any other application that does this, but I predict that in 15 years it'll be commonplace (and I'll still be poor)!

Re:Regexper – Regular expressions visualizer by ghusbands on Tuesday January 30, 2018 @04:50PM (#16269398)
Railroad diagrams for regular expressions were common long before 2005, and generating such images on demand isn't that unusual, so your work is unlikely to have been a major influence here. Similarly, automatically translating regular expressions from one engine to another is something that people have done before (out of necessity, for compatibility).
Re:Regexper – Regular expressions visualizer by ken on Wednesday January 31, 2018 @12:43AM (#16271728)
Do you have an example? I love reading original sources. I'd never seen a regex as a railroad diagram before that, though I admit it's entirely possibly I'd seen it somewhere and forgotten.

I don't know of any software that translates regular expressions, either, though I'm sure I can't be the first.

Re:Regexper – Regular expressions visualizer by dc_gregory on Wednesday January 31, 2018 @12:59AM (#16271806)
This fairly common piece of software does it.

https://www.regexbuddy.com

4th result on google for "regex conversion" for me. Seems like there are quite a few others.

Re:Regexper – Regular expressions visualizer by ken on Friday February 02, 2018 @11:41AM (#16291900)
I'm familiar with that program, but I see no railroad diagrams there.
Re:Regexper – Regular expressions visualizer by ghusbands on Saturday February 03, 2018 @02:25PM (#16299076)
They're replying to the "convert" part, which regexbuddy does [1]

[1] https://www.regexbuddy.com/convert.html

Re:Regexper – Regular expressions visualizer by ghusbands on Saturday February 03, 2018 @02:43PM (#16299168)
You seem to be chasing the idea that somehow your idea was formative, even though pretty much nobody will have seen it, even though you yourself don't know whether or not there were earlier instances.

Railroad diagrams are also called syntax diagrams [1] and were used in print as early as 1973 [2]. They are an obvious kind of diagram to use for regular expressions, which express a grammar/syntax.

Basically, many people will have had the idea, independently, because representing a regex as a railroad diagram is an obvious invention, as is converting them between variants. Doing these on demand is also obvious.

Trying to take some sort of credit (even as inspiration) for other people's work is not likely to make you many friends. The world is a vast place with many things going on independently. Keep on inventing.

[1] https://en.wikipedia.org/wiki/Syntax_diagram [2] Niklaus Wirth: The Programming Language Pascal. (July 1973)

Re:Regexper – Regular expressions visualizer by pdubroy on Wednesday January 31, 2018 @02:06AM (#16272120)
I think the first place I such a diagram was in the Smalltalk blue book. It has railroad diagrams for the language grammar. So not regular expressions, but very similar.
Re:Regexper – Regular expressions visualizer by theknarf on Wednesday January 31, 2018 @06:14AM (#16273035)
According to Wikipedia's article on railroad diagrams one of the first appearances of it was in "Pascal User Manual" written by Niklaus Wirth in 1973. Hardly a new idea. It's been used in academia for ages when first teaching regular expressions and Extended Backus–Naur form to students.
Re:Regexper – Regular expressions visualizer by patpatpat on Wednesday January 31, 2018 @12:02AM (#16271484)
Strfriend was very good, it helped me learn regex in a big way. Thanks!
Re:Regexper – Regular expressions visualizer by petagonoral on Wednesday January 31, 2018 @12:30PM (#16275563)
couldn't find jeff atwoods comment on twitter but he did have this to say on Stack Overflow back in 2009 [ answered Jan 13 '09 at 10:15 ][ https://meta.stackexchange.com/a/79880 ]:

It's even worse: those strfriend URLs in the form of

http://strfriend.com/vis?re=(Zip%3A\s*\d\d\d\d\d)\s*(State%3...

are really painful.You'll have to encode almost everything in it. See my edit.* Works now, but not worth it IMO.

str friend? more like str ENEMY.

Re:Regexper – Regular expressions visualizer by kyberias on Tuesday January 30, 2018 @02:50PM (#16268370)
I was taught the algorithms to do this stuff in my Computer Science class over 20 years ago (RE is equivalent to DFA). You weren't the first person to implement regular expression visualizations.
Re:Regexper – Regular expressions visualizer by skate22 on Tuesday January 30, 2018 @03:05PM (#16268514)
A dynamic visualization on the web 13 years ago? He may have been the first.
Re:Regexper – Regular expressions visualizer by osteele on Tuesday January 30, 2018 @09:42PM (#16270908)
It was pretty hard to do viz on the web 13 years ago. In 2006 I made a web tool to turn regular expressions into NFAs and DFAs and animate their states as you typed. It took a lot of code (drawing and animating along beziers, AJAX to a server for graphviz and a regex compilation and minimization package I wrote for this). https://imgur.com/gallery/Yqqoh

These days there’s a lot more tooling and components that can snap together to make this kind of thing.

Re:Regexper – Regular expressions visualizer by dspillett on Wednesday January 31, 2018 @05:26AM (#16272865)
> A dynamic visualization on the web 13 years ago?

Depends on what you count as dynamic, but I think so yes. There was one in use at my Uni ~2000. Obviously there were no fancy canvas/svg options to work with client-side (though IIRC flash was very much a thing by then so that could have been used) so it produced an image server-side that was updated when you submitted a change.

Not entirely dynamic due to the manual post to the server for each update of the diagram, but it counts IMO. It could have been more automated via the JS/Dom methods available at the time I'm sure, I can think of a couple of ways, but I don't remember it being so.

> He may have been the first.

I'd say not the first. He may well have come up with the combination of ideas independently. How many times have you thought "X would be brilliant, I'm a genius" only to find when describing the idea to other that several "geniuses" preempted you and it already exists (or worse: it has been tried and proven to be a terrible idea in practice)! It has certainly happened to me a fair few times, and back then it wouldn't have been as easy to search out similar ideas/implementations.

Re:Regexper – Regular expressions visualizer by ken on Wednesday January 31, 2018 @12:40AM (#16271711)
I studied computer science, too. DFA graphs are not the same as railroad diagrams.