I've put the regex at https://gist.github.com/kmill/17c5ef4f99bd9ef7ad799f0b487448...
The amusing thing to me is that this regex visualizer can reproduce the comic.
51–60 of 108 posts
I've put the regex at https://gist.github.com/kmill/17c5ef4f99bd9ef7ad799f0b487448...
The amusing thing to me is that this regex visualizer can reproduce the comic.
Also having each character of an alternation of subset in light blue box then laying them out vertically makes the hard to read.
Of the point of this is to make regex more easily understood, you would think you would want to make them compact.
Nice. From this SO answer: https://stackoverflow.com/a/800847/415384 we get this: https://regexper.com/#%5E(%3F%3A(%3F%3A(%3F%3A0%3F%5B13578%5... or from another answer: https://regexper.com/#((1%7C0(00)*01)((11%7C10(00)*01))*%7C(... )
Thad first one doesn't seem very good. It seems like there are many places states could be merged. Eg, there are 4 different "^0" states and 3 "^1" states. or am i misreading something?
Earlier quoted context omitted.
The visualization tool shows that the regex is not correct. It allows 000.000.000.000 as an IPv4 address
I created this instead: https://regexper.com/#((%5B0-9%5D%5C.)%7C(%5B1-9%5D%5B0-9%5D... The repetition count seems to be displayed off-by-one though.
After 20 years of software development I‘ve come to adopt a best practise: Whenever I start writing a regular expression, I stop and write a „manual“ domain specific parse function instead. Saved me a LOT of debugging time. Since I can now use kotlin pretty much anywhere (jvm, browser, shellscripts) this is easy because of the superb stdlib („startsWith“, „lastIndexOf“, „substringBeforeLast(...)“) The time saved I in…
I can't shake the feeling that Regexp could be written just as efficiently as a fluent interface with a more human friendly syntax. I've been telling Jr devs bucking for promotion for years to explain what they're doing in plain english, then write code that looks like that. Basically telling them to skip right over the "gee look what a clever fuck I am" stage and write good code instead of creating riddles. The Rege…
regexReplaced n = do
char 'T'
spaces
x
The above is a Haskell function that does the parsing required above, returning the alphanumeric characters if the parse succeeds and returning an error if it does not. You may not speak Haskell, but this is probably still more readable than (n) => {new RegExp(`T\s(\w{${n}}\w)\s*=`)}, which is the Javascript function that does a similar thing.Earlier quoted context omitted.
Wow, that is really cool. I actually started typing in random characters and tracing the matches through the graph for the Regex from StackOverflow mentioned earlier. I didn't know what the regex matches, so I played it like a game , trying to reach the finish by typing one character at a time. When I finished, I saw that I had typed "01/31/1691" and then realised that it's a regex for dates.
Sounds like you'd love https://regexcrossword.com/
Neat! I also suggest: https://regexr.com/
After 20 years of software development I‘ve come to adopt a best practise: Whenever I start writing a regular expression, I stop and write a „manual“ domain specific parse function instead. Saved me a LOT of debugging time. Since I can now use kotlin pretty much anywhere (jvm, browser, shellscripts) this is easy because of the superb stdlib („startsWith“, „lastIndexOf“, „substringBeforeLast(...)“) The time saved I in…
I can't shake the feeling that Regexp could be written just as efficiently as a fluent interface with a more human friendly syntax. I've been telling Jr devs bucking for promotion for years to explain what they're doing in plain english, then write code that looks like that. Basically telling them to skip right over the "gee look what a clever fuck I am" stage and write good code instead of creating riddles. The Rege…
You may be interested in the Parse dialect of Red:
http://www.red-lang.org/2013/11/041-introducing-parse.html
Also worth noting that Red can be embedded in any program that supports a C function interface, through using LibRed.
http://www.red-lang.org/2017/03/062-libred-and-macros.html?m...
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…