Live data from Hacker News

Regexper – Regular expressions visualizer

regexper.com

101–108 of 108 posts

Re: Regexper – Regular expressions visualizer

#101
Nicely done.

Next step, can you do it in reverse? Would be cool to create the regex in a graphical editor and then generate the actual expression.

Feature request: export the visualization to ascii, so I can copy paste it into a comment above the regex in my code.

Re: Regexper – Regular expressions visualizer

#102
Here's an example of a regex to validate us phone numbers

https://regexper.com/#%2F%5E(1%5Cs%3F)%3F(%5B0-9%5D%7B3%7D%7...

From

https://www.freecodecamp.org/challenges/validate-us-telephon...

I found these 11 videos most helpful when learning regex from codecourse

https://www.youtube.com/watch?v=GVZOJ1rEnUg&index=1&list=PLf...

Re: Regexper – Regular expressions visualizer

#103
post #40

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 Twitte…

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

#104
post #100
post #83

Earlier quoted context omitted.

In IPv4 addresses, as far as I know, this is not done -- it is only IPv6 addresses that use the double colon to indicate a sequence of zeros.

Where are you seeing a double colon? He write "10.1", not "10::1". IPv4 addresses, according to POSIX, can be written in 4 forms: A1.A2.A3.A4 A1.A2.B A1.C D where Ai is an 8 bit number, B is a 16 bit number, C is a 24 bit number, and D is a 32 bit number. "10.1" is A1.C form. See the inet_addr man page if you are on Unix or a Unix-like system.

I referred to the double colon as something I saw used with IPv6 to indicate a sequence of 0's.

I wasn't aware that inet_aton supported all these forms and the regex I provide won't parse them. It seems like inet_aton supports specifying the numbers in octal and hex too.

Re: Regexper – Regular expressions visualizer

#105
post #89

Earlier quoted context omitted.

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.

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.

I'm familiar with that program, but I see no railroad diagrams there.

Re: Regexper – Regular expressions visualizer

#106
post #105

Earlier quoted context omitted.

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.

I'm familiar with that program, but I see no railroad diagrams there.

They're replying to the "convert" part, which regexbuddy does [1]

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

Re: Regexper – Regular expressions visualizer

#107
post #89

Earlier quoted context omitted.

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

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.

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

#108
post #100
post #83

Earlier quoted context omitted.

In IPv4 addresses, as far as I know, this is not done -- it is only IPv6 addresses that use the double colon to indicate a sequence of zeros.

Where are you seeing a double colon? He write "10.1", not "10::1". IPv4 addresses, according to POSIX, can be written in 4 forms: A1.A2.A3.A4 A1.A2.B A1.C D where Ai is an 8 bit number, B is a 16 bit number, C is a 24 bit number, and D is a 32 bit number. "10.1" is A1.C form. See the inet_addr man page if you are on Unix or a Unix-like system.

Great explanation thank you! The 24 bit and 16 bit variants are highly useable but they are often overlooked by regexps, biggest problem is web apps. Being able to use octal and hex is even less common.
Post reply on HN