CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Stumped by Regex



Dec 6, 2006, 6:11 AM

Post #1 of 2 (426 views)
Stumped by Regex Can't Post

Hello, Hope someone can help.
I need to find a regex to take a surname (any surname) from a form with <STDIN>,
It must take "double-barrel" names into account (ie those with a space in the middle), but the whole string must be no longer than 20 characters. It must start with a letter and end with a letter with the space (or no space) appearing somewhere in the middle. It must also cater for normal single word surnames.

This is what i have so far (but doesnt limit to 20 characters)


I bet this is simple but for the life of me i cant figure out the regex i need.



Dec 16, 2006, 2:20 PM

Post #2 of 2 (413 views)
Re: [stupeas] Stumped by Regex [In reply to] Can't Post

You're on the right track. There are 2 problems with what you have. The first is that the part which matches alphabetical characters only matches 1 character the first time, and 0 or 1 characters the second time. The second is that you are allowing a space character to possibly be the last character.

Here is what you are after:


>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives