Live data from Hacker News

RegExr: A website for interactive regex prototyping with syntax highlighting

regexr.com

51–60 of 72 posts

Re: RegExr: A website for interactive regex prototyping with syntax highlighting

#51
post #34

I had the older version bookmarked http://gskinner.com/RegExr/ which now redirects to this site. Some other good sites that I've used are: http://regviz.org/ https://regex101.com/ http://osteele.com/tools/rework/ http://www.rexv.org/ https://www.debuggex.com/

Regex 101 is fantastic, I love how it provides a plain english explanation.

Re: RegExr: A website for interactive regex prototyping with syntax highlighting

#53
post #4

Nice work :) Looks like this tool puts the emphasis on the pedagogical aspect. For development, the most fantastic tool that I know of in this space is debuggex. Here is an example with roman numbers: https://www.debuggex.com/r/Xqlv3QcAuw_EgPSM

I think Regulex actually has a nicer visualizer, but it lacks all the other features of debuggex and regexr.

https://jex.im/regulex/

Re: RegExr: A website for interactive regex prototyping with syntax highlighting

#54
post #5

RegExr looks really nice, but my go to is still http://rubular.com .

What do you think makes it better? I think the UX on rubular is much cleaner. Don't they both serve a different flavor of regex?

Rubular uses Ruby's regex engine (Oniguruma/Onigmo). Regexr uses your browser's RegEx engine.

That doesn't make it "better", but it does mean they have slightly different purposes. You can use Ruby specific regex features with Rubular, so it is "better" for Ruby regex development.

As a general principle, I like to test against the same regex engine that I'll use in production. If I'm writing Ruby, I'll use pry/irb or a tool like Rubular. If I'm writing Javascript, you'll find me in the closet with the barrel of a gun in my mouth... I mean, I'll test against my target browsers using their respective web inspector, or use a tool like RegExr.

An example of the differences in the engines, the Onigmo engine supports conditional sub-patterns:

Rubular: http://rubular.com/r/zUwSsIi117

Regexr: http://regexr.com/3b1vn

As far as browsers go, they're actually pretty close most of the time. ECMA specifies regex (I think), so if you stick to the ECMA standard, you should be fairly safe. As with anything in browser-land, you'll encounter edge-case inconsistencies that will bite you in the ass.

Re: RegExr: A website for interactive regex prototyping with syntax highlighting

#56
post #21

I've been programming for about two decades. I had composed three regexes before my first coffee and before seeing this article this morning. My problem: I still don't have a good mnemonic to remember how magic differs grep, egrep, vim, awk, Perl, Python, etc. If that this site had modes and flavoured cheat-sheets I would live there!

I use RegexBuddy, it has a shitload of different modes.

I love and miss RegexBuddy! If only they had a Mac/Linux version :( I've had thoughts about switching back to Windows while developing complex regular expressions.

Re: RegExr: A website for interactive regex prototyping with syntax highlighting

#57
post #42

Earlier quoted context omitted.

this seems incredibly easy to add given what they're done - just send a note to the author. I can't imagine how it wouldn't take seconds to implement.

It is actually true for PCRE (PHP), Python, and and a bit for non-global Javascript regex. For global matches in JS it is, I dare to say, incredibly difficult, if not impossible. I haven't seen visualised submatches in JS anywhere. I'd be happy to be mistaken and corrected. So go on, try it right away :] I think it might be possible to get it done with breaking original regexp into group tree and look what each part…

Author of Debuggex here.

Debuggex actually has the /g flag always enabled (the example above happened to have just one match), and it works for JS [1]. Groups for JS are indeed quite tricky. However, they come for free if you implement state visualization, since you need your own regex engine to do that (and can use said engine for the position of groups).

[1]: https://www.debuggex.com/r/wSCkdE0_MNrysz4x

Re: RegExr: A website for interactive regex prototyping with syntax highlighting

#59
post #57
post #42

Earlier quoted context omitted.

It is actually true for PCRE (PHP), Python, and and a bit for non-global Javascript regex. For global matches in JS it is, I dare to say, incredibly difficult, if not impossible. I haven't seen visualised submatches in JS anywhere. I'd be happy to be mistaken and corrected. So go on, try it right away :] I think it might be possible to get it done with breaking original regexp into group tree and look what each part…

Author of Debuggex here. Debuggex actually has the /g flag always enabled (the example above happened to have just one match), and it works for JS [1]. Groups for JS are indeed quite tricky. However, they come for free if you implement state visualization, since you need your own regex engine to do that (and can use said engine for the position of groups). [1]: https://www.debuggex.com/r/wSCkdE0_MNrysz4x

In my examples, it looks like debuggex didn't match "\s" to newline in "...Z\n0..." but regex101.com does.

I don't know if that behavior for not matching newline matching is desirable since "\s" is supposed to include [ \t\r\n\f]. (See [1]) In any case, there doesn't seem to be an option in debuggex to make it behave like regex101 for my specific example.

[1]http://www.regular-expressions.info/shorthand.html

Post reply on HN