Live data from Hacker News

Regexper – Regular expressions visualizer

regexper.com

41–50 of 108 posts

Re: Regexper – Regular expressions visualizer

#41
post #12

Here is a regexp to match an IPv4 address - looks quite nice and easy to understand compared to the regexp! In fact the visualisation makes it easy to spot the mistake. https://regexper.com/#'%5Cb((25%5B0-5%5D%7C2%5B0-4%5D%5B0-9%... (From https://stackoverflow.com/q/5284147/164234 )

The visualization tool shows that the regex is not correct. It allows 000.000.000.000 as an IPv4 address

Re: Regexper – Regular expressions visualizer

#43
post #42

Looks neat, but after a quick look I think I still like https://www.debuggex.com/ better. Going step by step through the regex for a given string is really a killer feature for me.

Yep, and not having to click "Display" button each time.

Also, partially highlighting the text you write is a pretty hard feature to implement, I did it once. Kudos to debuggex.com for working correctly even with browser zoom on.

Re: Regexper – Regular expressions visualizer

#44
post #16

The Email::Valid Perl distribution ships with a more than 6000 character regex to validate E-Mail addresses. Both goo.gl and bit.ly refused to shorten it, and when I tried to paste the link here HN refused to accept my comment. But on a machine with Email::Valid installed do: perl -MEmail::Valid -wE 'say $Email::Valid::RFC822PAT' And copy the output into the Regexper form. It takes a while to render, but it'll eventu…

This short link seems to work:

http://1b.yt/exfqj

(regexper.com doesn't seem to cache results, so this is going to hit their site hard...)

[edit: oops, it's all client-side so no problem for the site]

Re: Regexper – Regular expressions visualizer

#45
post #37

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 Regexp problem just screams this at me. What am I doing? I'm looking for a line that starts with a capital T, then has some quantity of alphanumeric characters greater than n (if n is not 0, 1, or infinity, this requires extra work in Regex), followed by an equals sign with or without whitespace characters around it.

Give me an API that does exactly that, instead of Regex. Something gets lost in translation every time.

I think the fact that the origin of Regex is the command line interface is pretty telling. We didn't and we don't have a convenient way to type in imperative code on a command line. So an arcane syntax was created so you could do the whole thing in a quarter line of text.

Speaking as someone who has had a Unix shell for 25 years, and routinely works on mini tools for their fellow developers, I don't think we actually type stuff into a shell that often anymore. The difference between documenting a one-liner in a README and just building a shell script that does the same thing is not that big. There's a difference in development effort but building a script can allow you access to a debugger. Personally, I'd be willing to pay that tax any day.

Re: Regexper – Regular expressions visualizer

#46
post #37

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…

Yep. I primarily use Go, so you are often forced down this way because it uses a simpler regex engine. I used to complain but in hindsight I realized it was a blessing in disguise. Particularly in Go's case, it has excellent character set library support, especially unicode, so those really tricky corner cases with unicode characters are non-existent now as well. I will be happy if I never see a regex with a unicode…

Which IDE do you use?

Re: Regexper – Regular expressions visualizer

#47
post #45
post #37

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…

I agree. That’s why I pointed out that a necessary addition to get more productivity out of writing custom parsers is

a) easy usability in shellscripts B) easy tooling for unittests

I started writing shellscript in kotlin, so i get the unittests for free

Re: Regexper – Regular expressions visualizer

#48
post #5

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?

Re: Regexper – Regular expressions visualizer

#49
post #41
post #12

Here is a regexp to match an IPv4 address - looks quite nice and easy to understand compared to the regexp! In fact the visualisation makes it easy to spot the mistake. https://regexper.com/#'%5Cb((25%5B0-5%5D%7C2%5B0-4%5D%5B0-9%... (From https://stackoverflow.com/q/5284147/164234 )

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.

Post reply on HN