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

Re: [FWP] Gender differentiation



> i -think- this will do it:
> 
> /((?!wo)..|^.?)men/i;
> 
> we want: 
> - the string 'men',
> - preceded by either:
>   - two characters which are not 'wo', or
>   - just one character, or
>   - zero characters.
> 
> here's the script and data i tested the regex with:
> 
> while (<DATA>) {
>   print if /((?!wo)..|^.?)men/i;
> }
>   
> __DATA__
> Some women walking.
> Some men walking.
> Woman is singular.
> Man is singular.
> Men is plural.
> There are men-working here.
> Dancing women prove sexist, news at 11.
> Snowmen are built by snowwomen.
> Omen!  Y2K!
> Women usually know what they're talking about.
> Snowmen.
> Snowwomen.
> 
> --
> Steve Lane <sml@zfx.com>

Coool, and I thought TNWTDI. This is fun. I now have a reason to upgrade to
5.005, a way to do it in 5.004 and best of all I can now tell the snowwomen
from the snowmen without wasting a regex. Thanks!

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