How to learn regular expressions

Hi.
I want to learn regular expressions.
How is the best way to do this?

I need to use especially to manipulate large parts of text extracted from InDesign.

Thanks for help

For a general Tutorial try this:
http://www.regular-expressions.info/tutorialcnt.html

Perl has the most advanced RegEx capability, so I suppose you want to use Perl, right?
Here you can find the official PERL RegEx Manual:
http://www.perl.com/doc/manual/html/pod/perlre.html

And here you find everything else you might ever need:
http://www.google.com/search?q=perl%20"regular%20expressions"%20manual

Good luck!

Ps: I learnt RegEx about two years ago and I couldn’t live without them anymore.
IMHO it’s a shame that Apple didn’t make RegEx a systemwide standard feature of Mac OS X.:/:mad:

regular-expressions.info is fantastic. As far as really learning goes, I would recommend just to get a graphical regex-capable editor (like TextWrangler) and just start playing with them. First, grab some HTML source (for example), write out the pattern in english (or your native tongue) and then translate that into a regex. The TextWrangler manual also has a very handy regex section.

As far as books go, I would heartily recommend the Regular Expressions Pocket Reference from O’Reilly. It’s cheap and extremely useful.

Good luck!

Anyone who really wants to know regular expressions in and out should have this book:

http://www.amazon.com/Mastering-Regular-Expressions-Second-Jeffrey/dp/0596002890

This is the regex bible. Period.

You say this like it’s trivial to implement regular expression engines, as well as make them accessible to all kinds of differently implemented API layers.

No, it’s just that there are so many things where you could implement RegEx very easily:

  • Spotlight: How often do you have to search for files on your HD whose names I’d have to enter one by one. Often you could do this easily by using a single and quite simple RegEx.
    (For the geeks we have GREP, I know . but in most cases a terminal text list of filepaths doesn’t help that much.)
    Though I have to admit this is not the only reason why I kinda hate Spotlight :mad: But that’s another story :rolleyes:

  • Plain text editing: I wrote my own RegEx app for Mac OS X which is called Textreme (www.satsumac.com/textreme.php) as there simply is no pleasing GUI way to work with RegEx on Mac OS X.

  • Rich text editing: Nisus Writer Express does handle RegEx with rich text. It therefore is possible. Not always the best way to go but possible.

You said “systemwide standard feature” at first, and now you’re talking about only one or two places.

Which one are we actually talking about, here? The two are very different.

I don’t think so.

The Find&Replace function for NSTextViews can be accessed by any Cocoa app systemwide.
It is a standard feature from Apple, and accessible in any app. (unless the dev disabled it)

The Spotlight functionality can be used by any Cocoa app systemwide.
In opposite to the “Find&Replace” window it needs some coding to be implemented but it still is a standard feature and systemwide accessable.

I don’t see RegEx as a standalone feature, more like a method to improve a functions workflow/results.

RegEx brings benefits for searching/matching patterns and replacing the stuff afterwards. And that’s exactly what I described in my last post, didn’t I?

What else place could you think of?

Maybe I just didn’t make myself clear enough, though.:rolleyes: