RegExr: A website for interactive regex prototyping with syntax highlighting
regexr.com
regexr.com
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)
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.
Nevertheless, I prefer explicit color-coding highlighting the boundaries instead tooltips displaying the offset numbers.
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 :)
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).
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.
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:
https://regex101.com/r/eB5jY1/1
https://www.debuggex.com/r/mci3WLNmHGTEatf6
For development, the most fantastic tool that I know of in this space is debuggex. Here is an example with roman numbers:
Example regex: https://regex101.com/r/wY0rM7/1
Don't they both serve a different flavor of regex?
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.
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.
Also, https://regex101.com is very good alternative
Paste a sample line, mark the parts you like, it generates a piece of code to extract just those parts. Has saved me hours.
It's evolved a lot since then :)
One of my other favourites: https://jex.im/regulex , a regex visualizer.
Don't know if it made HN when it was released.
emacs
M-x regexp-builderIn the past, when I've looked for a good Internet RegEx test site, I've had trouble finding one that "does" the Java dialect.
I wish there would be one single standard to regexes. Great tool but difficult to use because of many incompatible implementations.
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.
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.
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).
Simple, minimalist, takes up all available space in the viewport & also works offline if you save the page.
- When did you begin this?
- What front-end JS framework did you program this in?
- How many visitors do you get per day?