in reply to Stumped by regex
Well, you have a lot of replies, and I think they all fail your spec. ... well done :).
This is probably what I would do...
sub surname { # Assumes ASCII locale $_ = shift; return undef if (length($_) > 20); return $_ if /^([a-zA-Z]+)$/; # Surname is only one return $_ if /^[a-zA-Z]+ ([a-zA-Z]+)$/; # Surname only return undef; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Stumped by regex
by brickwall (Acolyte) on Dec 06, 2006 at 18:10 UTC |