[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Gender differentiation




> I thought we also wanted to match 'snowmen' while leaving 'snowwomen' 
> alone. If there is a single regex to do that, that would be _too_ much
> fun :)

This seems to work:

  print
    /((\b|\b.|\b.*?[^o]|\b.*?[^w].)men)/
      ? "$_ matches: $1\n"
      : "$_ does NOT match\n";

"men" with no wordchars to the left;
"men" with any single wordchar to the left (including "o");
"men" with any number of wordchars to the left,
    as long as the one immediately to the left is not "o";
"men" with any number of wordchars to the left,
    as long as the one two places to the left is not "w".

John Porter


==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org