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

Re: [FWP] Gender differentiation



Steve Willer wrote:
> I've been trying to come up with a way to match "men" in any string, but
> not get a false match from "women".

Using the new enhanced REs from perl5.00503, you'd get

  /(?<!wo)[Mm][ae]n/

(gratuituously throwing in the solution for singular men at the start 
of a sentence).

Ain't look-behind assertions a great thing?

Being stuck with the old-fashioned REs, things get more complicated...

  /(?:[^o]|[^w]o|^.?)[Mm][ae]n/

[DARN! As I write this, solutions have already been submitted 
by two other Perlers. Oh, but I'll submit it anyway, just to 
satisfy my ego...]

Roland
--
perl -e '@_=@ARGV;$_="@_[-3,-2,-1]";s{([@{[$_[-1]]}])}#($0=$1.
${[qw[>$%, ()%{&", &"=, |}+&" *]]}[$@++])=~y/*=->$%&"(-){-}+,/
lusternohack /,$0#eg; print; '        -- Roland Giersig, JAPH.

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