Regular Expressions Tutorial

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Regular Expressions Tutorial

Post by FourthWorld » Sat Aug 09, 2014 4:27 pm

[-hh] wrote:certainly you know somebody, who is able to adjust in a few hours one of the "hundreds comprehensive tutorials available for regex" to the needs of LC. As I don't know anybody to do this in a few hours I ask for your support to get such a tutorial.
I wish I did. I rarely use regex myself (it's very convenient, but rarely as performant as pull-parsers for much of the stuff I do), and my other commitments prevent me from taking this on even if I was expert at it.

To find an author I'd recommend what you did here: post the request with an outline of what you're looking for, and hope that someone in the community has the time and interest to make it happen.

It may also be a good learning opportunity for anyone who has time but isn't an expert in regex yet. One of the best ways to learn something is to decide to teach it. Searching the forum, the list archives, the resources at livecode.com can probably pull up enough examples to serve as a good starting point for such a tutorial.
Idea for a practical application:
A simple Forum-RSS-reader, written in say 50 lines with the help of 'matchtext'. I wrote such a stack without matchtext/regex and needed more than 100 lines (and all is a bit 'beginners-like'). The current RSS tutorial stack doesn't work at all, uses xmlLib. Such a regex tutorial/RSS stack could be continuously adapted to the forum feeds, that certainly soon will use HTML5 and (extended) Unicode. Would be a wonderful demonstration of LC's new "text-handling-power".
There are many wonderful ways LiveCode is great at handling text, but personally I don't think RSS is one of them. The problem here isn't with LiveCode, but with the FUBAR disregard for convention exhibited by so many RSS generators. Just as there is no agreement about even what "RSS" stands for, there is apparently little consistency in how it's used, even on basic things like what CDATA means. RSS started out as a beautifully simple thing, but by the time the RDF folks got ahold of it they turned it into such a complex beast that now every author of RSS generators apparently feels at liberty to do whatever the heck they want with the format, so that today it's little better than CSV: a good idea at the time, its potential squandered by a lack of consistent implementation.

For the sake of the reader, I would recommend almost anything else, since even many aspects of rocket science are easier to understand than the nuances of RSS' bastardization.

Maybe parsing web logs might be a good start. That sort of analytics task is useful in so many ways, from measuring usability to marketing, and web logs are much more consistently implemented. The only downside is that they're so consistent that most of what we need to do with them can be done more easily with chunk expressions than regex, but ah, the unnecessarily unique date format web logs use, that might be a good fit for regex.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Regular Expressions Tutorial

Post by mwieder » Tue Aug 12, 2014 7:02 am

Not a tutorial per se, but here's a place to play with regex matchers and see their effects:

http://regexr.com/

Post Reply