http://qs321.pair.com?node_id=6187

Kozz has asked for the wisdom of the Perl Monks concerning the following question:

Is there a good plce to find information on all the available special characters, switches, options that can be used in a REGEXP string matching & searches? I feel comfortable with REGEXPs to a point, but I want to learn more about how they are used in matching, with things like m//g or s// or tr//isgcemx and all those letters that come BEFORE and AFTER the first and last slashes... Do I need to buy a book? Or is there a good webpage/site on this?

Replies are listed 'Best First'.
RE: Every REGEXP switch and option
by chromatic (Archbishop) on Mar 27, 2000 at 00:32 UTC
    The first place to start is perldoc perlre. If you're in a Unixy environment, just type that at a command prompt (I think it works that way in Windows too, but I rarely program there). With the Activestate compiler, HTML documentation is installed in your Start menu.

    From there, two excellent books are Programming Perl (from O'Reilly) and Mastering Regular Expressions (also from O'Reilly). Both are a little bit dated, but they'll have 98% of the information you're likely to need. Also check out places like perl.com for more up-to-the-minute information.

Re: Every REGEXP switch and option
by btrott (Parson) on Mar 27, 2000 at 00:31 UTC
    Have you looked at perlop and perlre? Those are, probably, the definitive sources on the regex switches and options. You might also take a look at Jeffrey Friedl's book, Mastering Regular Expressions. It's a bit outdated now, since there's been a lot of new regex functionality added since the book was published; but it's still a good source.

    By the way: the possible switches for the tr operator are

    tr//cds
Re: Every REGEXP switch and option
by turnstep (Parson) on Mar 28, 2000 at 22:44 UTC

    Another good source is the Perl Cookbook, Chapter 6. While it obviously cannot cover as much in one chapter as the Mastering Regular Expressions book, the chapter is excellent with many "recipes" and a good style that goes beyond the information in Programming Perl. Plus, you'll find the book invaluable for other things as well. Highly recommended. Available, of course, from O'Reilly:

    Perl Cookbook

    Update: Better yet, buy it through the unholy alliance of Fatbrain and Perlmonks here: Perl Cookbook :)