in reply to regex question

Are you sure you're testing correctly?
$ perl -le'$_="directoryy"; print if /(directory|file|age|action)/' directoryy $ perl -le'$_="directorys"; print if /(directory|file|age|action)/' directorys
Apparently the problem is somewhere else..

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: regex question
by gnu@perl (Pilgrim) on Sep 24, 2002 at 17:31 UTC
    Thanks for pointing it out. I did mis-state my problem. I only want to match if $_ is an exact match for the alternate. I only want to match on 'directory', not 'directorys' or 'directoryy' or 'cheeze whiz'.
      Use \b to assert a word boundary then. my $word = qr/\b(directory|file|age|action)\b/; Or ^ and $ to assert string start/end (respectively). my $word = qr/^(directory|file|age|action)$/; Or any combination of the two that you like. See perldoc perlre.

      Makeshifts last the longest.