Idiot's guide to regular expressions?

Kay C Lan lan.kc.macmail at gmail.com
Mon Sep 28 21:54:30 EDT 2009


On Mon, Sep 28, 2009 at 9:30 PM, Graham Samuel <livfoss at mac.com> wrote:

> Of course there is no shortage of other texts on regex to be found on
> Google, but can anyone suggest a concise primer that will help me parse
> ascii strings without too many tears? If there is one, maybe it's time to
> suggest that RunRev mention it in the documentation.
>
> Graham, unfortunately you don't mention which platform you're on, but for
those suffering similar, using OS X 10.4 or higher, may I suggest the free
RegExhibit:

http://homepage.mac.com/roger_jolly/software/index.html

Call up the Help Menu -> RegExhibit Help and check out "Regular expression
overview", it's in a seperate window so you can work with RegExhibit at the
same time as you read the Overview. Basically RegExhibit has two fields, you
copy and paste into the bottom field a sample of text you'd be working with.
In the top field you build your grep, as you build it characters in the
lower field start becoming colourised, you just keep building your grep
until you get a perfect match :-) Note there are different colours for match
vs capturing [using ()].

I use grep very infrequently and find RegExhibit a massive time saver.

I use to have a multi-platform Java app that basically did the same, but
trashed it once I found the faster RegExhibit; so if you are on Win, I'm
sure you can find similar out there.

Don't forget that within Rev there is the Rinaldi plugin RegExBuilder -
Development -> Plugins. It's basically the same as RegExhibit except no
Overview. It's perfect for double checking your grep behaves in Rev as it's
suppose to without having to write any scripts.

Finally, for Mac users again and those with pre 10.4 machines, the free, and
every Mac user should have, text editor TextWrangler from BareBones:

http://www.barebones.com/products/textwrangler/download.html

also has an excellent rundown on using grep. Go to the Help menu ->
TextWrangler Help, go to the Grep Reference hyperlink. Again you can enter
sample text into the main document window
and then enter your grep into the find window. It's not live like
RegExhibit, you have to keep hitting the Search button to see your results,
so it's not as fast.

HTH



More information about the use-livecode mailing list