Hacker News new | past | comments | ask | show | jobs | submit login
RegExr: A website for interactive regex prototyping with syntax highlighting (regexr.com)
384 points by sconxu on May 21, 2015 | hide | past | favorite | 70 comments



Unfortunately, RegExr does not color-code the different capturing groups.

For example, replace the RegExr sample regex with "([A-Z])\w+\s\w(\d.\d)" and compare[1][2] its color coding capability to the other regex helpers.

The other sites such as regex101.com & debuggex.com will delineate the capture groups within the matched text using different colors. This is very helpful for complex captures because making the boundaries visible can reveal bugs in your thinking of what substrings the regex is actually capturing.

(I don't intend to be negative. If capture group color-coding is an easy coding enhancement for RegExr, consider my comments as mentioning a minor nit.)

[1]https://regex101.com/r/eB5jY1/1

[2]https://www.debuggex.com/r/mci3WLNmHGTEatf6

(couldn't find a way to enable /g global on debuggex.com (even tried PCRE option) but color boundaries still show up on the 1st capture group)


Just wanted to chime in and give my recommendation for regex101.com that parent links to. This is by far the best regex "composer" I have ever used, on or offline.


Yup. regex101.com is really awesome and has been a time saver for me many times.


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 did on concrete match from global search using non-global match on local instances. You'd need own regex parser and watch out for deep nesting.


Then I think I misunderstood what jasode was asking. Specifically, the example (our link) already names groups if you hover over matching text (group #1, etc) - I thought they were just asking for the highlight color to correspond to the group # listed.


Thanks for mentioning the tooltip popups. I didn't realize RegExr used mouseover/hover events on the matching text since the other regex sites don't do that. (It seems like non-obvious UX/UI but I now notice that the bottom left corner does say "Roll over a match or expression for details" -- but who reads the instructions?!?! Nobody's got time fo 'dat.)

Nevertheless, I prefer explicit color-coding highlighting the boundaries instead tooltips displaying the offset numbers.


Interesting, somehow I just instinctively moused over the text when I first visited the page. Another example of the subjectivity of UX and need for UI to be explicit and versatile I guess.


yes, I only knew about the hovering because of the instructions, which I did read. FWIW, my reaction was it would probably be better if they were all visible at once, who has time to hover over stuff.

anyway since they have the logic to already know what to put in the tooltip, making that number determine a color seems like it would be simple, almost as simple as appending it to the tooltip. (if indeed that's all that's missing.)

email the author your suggestion :)


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


Ah, you're likely on a Windows machine. Debuggex will terminate lines depending on your system. So you would need \s\s to match both \r and \n


Interesting. That's very subtle behavior. (Especially since it sometimes fools one into thinking /g option is not enabled when in reality, it's a CR+LF issue.)

I'm not saying your site's interpretation of Windows CR+LF is "wrong" but the other 5 online[1] regex testers don't behave that way on Windows Chrome browser. I also tested the regex and target text on desktop JGSoft RegexBuddy[2]. None of those required "\s\s" instead of "\s".

Debuggex at the least, is very idiosyncratic since the majority of the other testers don't treat CR+LF that way.

[1]regex testers tried with "([A-Z])\w+\s\w(\d.\d)" on Windows:

http://regexr.com/3b22q

http://regviz.org/

http://www.rexv.org/

https://regex101.com/r/eB5jY1/1

https://www.debuggex.com/r/mci3WLNmHGTEatf6

[2]http://i.imgur.com/t2L04mO.png

(http://www.regexbuddy.com/)


Neither choice is great (the other ones that I've tried auto-convert \r\n to \n so it's impossible to test a \r\n string). I don't think there's anyone in particular that's at fault, \r\n causes a messy set of problems.


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


Out of all the links posted in this thread, https://www.debuggex.com/ is by far the best especially because of it's visualisation.


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

https://jex.im/regulex/


Dude, that is way cool. This is like one step away from FSMs.


You can step through the FSM on Debuggex by using the sliders :)


I really love this one!


My favourite is still https://regex101.com

Example regex: https://regex101.com/r/wY0rM7/1


Came here to give this a mention, it's a really valuable tool


I absolutely love this tool. I've been writing regexes to scrape some data recently and it has been a lifesaver.


Same here, I loved regex101 :)


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/


I'd add http://regexpal.com/ for historical completeness. It's the first such tool I used and prefer it even today. Very sad that from what it seems Steven Levithan sold entire domain recently and is not updated anymore. Even permalinks broke last year. (I'm a bit worried, what's up with Steven.)


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


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.


Rubular is my go to as well, even though I primarily write JS expressions and there are some gotcha.

Having the numbered capture groups and clean simple interface is amazing. I also test and create tiny urls embedded in my code to show how the expression work. Handy for coming back later and making changes.

I don't doubt there is something better, but it is still hard to change.


For me, it's lightning fast with no clutter. I just want quick verification that the regex I'm writing matches a few samples. Explaining to me that `+` matches "one or more of the preceding group" adds no value.


I have been a regular user of this website for quite some time now. I like the UI and usability is great.

Also, https://regex101.com is very good alternative


My favorite tool for quick regex definition to text extraction is http://txt2re.com/

Paste a sample line, mark the parts you like, it generates a piece of code to extract just those parts. Has saved me hours.


RegExr is my go to regular expression playground. I've been using it for many years, back when it was on http://gskinner.com/RegExr

It's evolved a lot since then :)


For anybody doing .NET development, RegexHero (http://regexhero.net/tester) is nice. It uses Silverlight though...


Will be bookmarked alongside my other regex helpers.

One of my other favourites: https://jex.im/regulex , a regex visualizer.


http://regexp.quaxio.com/ tries to act as a linter.


That's a great project by @amenghra and Facebook's Hack creator Julien Verlaguet!

Don't know if it made HN when it was released.


Oh wow, always cool to see stuff Julian has done!


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.


Regexbuddy can be run on a Mac using Wine.


Can it also translate regexes from one flavor to another?


  emacs

  M-x regexp-builder


Sorry if this information is visible somewhere: Which dialect of regexp does RegExr "do?"

In the past, when I've looked for a good Internet RegEx test site, I've had trouble finding one that "does" the Java dialect.


What I am missing is some kind of service to convert between different types of regexes. Like Java, Intellij Idea Search&Replace, vim, less, grep, egrep, sed. There are subtle (and sometimes not so subtle) differences between them which I always forgetting and have to trial&error a bit.

I wish there would be one single standard to regexes. Great tool but difficult to use because of many incompatible implementations.


I've been using RegExr for years, it's the first place I go to when I have a tricky regular expression to put together. It works really well.


My favorite is regulex[1] a visual explanation of regex

[1] https://jex.im/regulex


http://regexper.com/ does the same thing.

I just wish there was something like this in reverse. Somewhere I can drag and drop the visual nodes and have it return the regex string to me.


This is awesome, but I like https://regex101.com/ more


Suggestion: allow use of extended regexps too (I have a quick JS function to enable this, which you can regard as public domain: http://blog.mackerron.com/2010/08/08/extended-multi-line-js-...).


Sites like this is great and all, but I wish they included some commonly used regexes. Like a list of 'good' regexs to validate phone numbers, emails and other common stuff.

It would actually be pretty cool to have a site like this except you could add the regex to a list, and then people could upvote the regexe depending on the quality of it.


You can only validate a zip code, a phone number, an address, or an email address using a regex up to a point.

There are too many dispartities from a country to the next for the first three to hope validating anything withhout a bunch of false negatives. Some countries don't have zip codes.

For emails, blindly following the RFCs yields a monster (see [1]), and it won't help you if you run into oddball email addresses that are not RFC-compliant but work regardless due to technical implementations (or vice versa).

http://regular-expressions.mobi/email.html


...and I just checked the community link. Way to go :-)



I've been looking for something like this on mac since I moved away from windows long time ago, no RegEx Buddy, such a great tool too. I think that I discovered regexr a year ago. This is such a great tool. Much appreciated work from @gskinner and community.


I've tried a number of these and this is the one I've gotten along with best:

http://jsregex.com/

Simple, minimalist, takes up all available space in the viewport & also works offline if you save the page.


I really like the regexp syntax coloring. What makes me still reach out for rubular.com, is actually the regexp cheat sheet on the bottom of the page. After 25 years, I still like to have a cheat sheet for regexp to remember all the swithces etc.


Probably my favorite tool on the internet. One thing I wish it had was an implicit select option like grep -o since I frequently find myself using it to do interactive text manipulations for one offs.


http://refiddle.com/ is a similar service I've found useful.


Is there a service that would allow one to enter positive matches and negative matches and it would then deduce a regex suggestion for that?


My favorite for Python is still http://www.pyregex.com/


This has been my go to regex testing site for years. Absolutely love it.


Cool! These are the same guys behind CreateJS. Amazing work as well.


this has been posted a few times, but is a great resource


Author:

- When did you begin this?

- What front-end JS framework did you program this in?

- How many visitors do you get per day?


You will probably get some info from the author's blog: http://blog.gskinner.com/archives/2014/03/regexr-v2-build-te...


This official repo might help; https://github.com/gskinner/regexr/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: