Now, I know both SQL and regexes just fine, but a few times on this site, I came across someone working through the exercises on SQLzoo.net. As far as I could tell, this was a wonderful online resource where someone can pretty easily learn SQL by example, writing many toy queries against several toy databases. I will likely redirect people wanting to learn SQL to that site.
These SQLzoo people also run some other tutorials, including some on a few programming languages. However, the section on regular expressions is pretty small (e.g., see Java's page), and I don't think you can actually learn regexes from it. I think a good, online tutorial might help with the onslaught of basic regex questions we have here. (Maybe after the answer, we could suggest that they take a look at the tutorial.)
So, is there a good, online, interactive regex tutorial along the lines of that SQL tutorial? I looked online briefly, but all I could find were non-interactive tutorials or simple pages (still useful, though!) that let you match a string against a pattern so that you could see what it matches/captures/etc.
A great place to head for RegEx testing and practice is Rubular - it allows you to build and test regular expressions against text that you define. In a separate window, open up Rubular.
Regex isn't suited to parse HTML because HTML isn't a regular language. Regex probably won't be the tool to reach for when parsing source code. There are better tools to create tokenized outputs. I would avoid parsing a URL's path and query parameters with regex.
You can learn in 2 months.
Shameless plug: I wrote an interactive Regular Expression tutorial (RegexOne) over a couple weekends to help some friends learn regular expressions. They mentioned the real time examples seemed to help quite a bit too.
The site written by @wchung, RegexOne seems to be a perfect answer to the original question. Check that out first ;)
The tool txt2re is, as commenters have rightly mentioned, very ugly. RegExr (ht @runrunraygun) is a much prettier tool for editing regular expressions, although has completely different functionality and still no tutorial.
The main reason it might be useful for learning regexes is the ability to see the effect each edit is having on the matching.
Original answer:
I always thought txt2re was a very clever tool. You just type an example of some text you want to match, and then it lets you pick bits out to match against. I'd consider it to be a fairly useful tool for learning regular expressions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With