python-discord/meta

Resource Suggestion: regex101

swfarnsworth opened this issue · 5 comments

Resource location
https://regex101.com/

Payment type
Free, but solicits donations

Why it should be included
We don't currently have any regex resources, and it looks like this one combines both regular expression testing (as a tool) and interactive regex tutorials.
I've always used pythex, which is just an expression tester with a syntax cheat sheet, but this seems to have more features and is the one I've seen more staff members using.

Potential limitations
It supports multiple languages and lists Python as "Python 2.7", which might be confusing.

So, is this better than pythex? Discuss.

I've been using regex101 for years, and I don't think it's ever come up short for what I needed. I hadn't used pythex before, so I checked it out in order to compare.

Benefits of regex101 over pythex:

  • Supports multiple programming languages. I don't know how much we care about this given our focus on python, but from the user's perspective it would be convenient to have one tool for regex rather than one for each language.
  • The big one: gives the user a breakdown in English of what their pattern means, organized by groups. Also provides the same information on hovering over the pattern, parsed into groups, classes, and sequences, and even color-codes them. The two hard parts of understanding a regex pattern are knowing what an exotic sequence does and seeing the overall structure of the pattern. This feature elegantly solves both.
  • Provides detailed match and group information both in a sidebar and color-coded on each test string. Shows you which part of the string was "consumed" by which part of the pattern. Pythex provides match and group info, but it's a bit less clear and isn't color-coded.
  • Has multiple modes: normal matching (same as pythex), substitution, and unit tests. (To be honest I can't figure out what the List mode is for, but it does exist.)
  • Can auto-generate code so you can see how your regex patterns are supposed to be used with python functions.
  • Has more comprehensive options for string delimiters and regex flags. For example, you can give pythex a pattern that includes both ' and ", and it will accept it without mentioning escape characters. In regex101 you have to explicitly choose a string delimiter (which can be """ or ''' as well), and it will warn about unescaped delimiters in the pattern.
  • Both have a regex cheatsheet, but regex101's is interactive and searchable, so IMO is a bit nicer to use.

Benefits of pythex over regex101:

  • As far as I can tell, there's no way to bookmark the python language for regex101, whereas pythex is of course focused on python. This is a minor annoyance, requiring a click after loading regex101.com.
  • The python feature is listed as "Python 2.7". I don't actually know if that's any different than the regex in python 3 (I've never come across an inconsistency), but it could be slightly misleading. Pythex does not specify any particular version of python.

I strongly prefer regex101, both for experienced users testing patterns and for beginners learning regex. I think it would be a great resource to include on the site.

@camcaswell thanks for your thorough review!

Here's a question I should have raised before: what topic does regex fall under? I'm thinking of putting it under both "other" (because they're useful in general but aren't a core programming skill) and "data science" (because I know I use them for data science). Do you think it belongs under any others?

Maybe UI/UX and Webdev Front-end, since regex is commonly used for user input?

Unrelated to regex101, but what I used to learn was regexone.com - I feel like it is much more approachable as a beginner to get started with regex (it is an interactive course). I think it is worth considering to add as a resource as well.

I'm going to go ahead and close this as regex101 is now included in a development branch for this project.

@anand2312 feel free to open a new issue for regexone.