Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Stumped by regex

by nevyn (Monk)
on Dec 06, 2006 at 16:10 UTC ( [id://588122]=note: print w/replies, xml ) Need Help??


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; }
--
And-httpd, $2,000 security guarantee
James Antill

Replies are listed 'Best First'.
Re^2: Stumped by regex
by brickwall (Acolyte) on Dec 06, 2006 at 18:10 UTC
    Thanx for all the replies guys. Although some of them dont quite do it. In the end i figured out that the following will do the job (with the addition of some varification error messages for the user), and then check for length with an "if". Thanx guys
    m/^[a-zA-Z]+\s?[a-zA-Z]*$/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://588122]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-03-19 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found