php-general Digest 1 Jan 2011 14:36:19 -0000 Issue 7111

Topics (messages 310439 through 310441):

Re: Regex for telephone numbers
        310439 by: Daniel P. Brown

Regex for ... genealogical names
        310440 by: Lester Caine
        310441 by: Ashley Sheridan

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Fri, Dec 31, 2010 at 19:09, Jim Lucas <[email protected]> wrote:
>
> Actually...
>
> Specified here [1] it says that the {1,} is the same as '+'.  I think you 
> should
> drop the comma.  If you don't this would be valid 844-2345-123456
>
> ^[2-9]{1,}[0-9]{2,}\-[2-9]{1,}[0-9]{2,}\-[0-9]{4,}$
>
> should be
>
> ^[2-9]{1}[0-9]{2}\-[2-9]{1}[0-9]{2}\-[0-9]{4}$

    Bah, you're absolutely correct.  Force of habit with the commas.
I didn't even notice the sample test cases I put into that test array
didn't check for more than the number of digits per field, either.
Good catch, Jim, and Happy New Year.

-- 
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--- End Message ---
--- Begin Message ---
A slightly more complex problem than phone numbers ...

It is a sort of convention to use the format 'JohnDoeSMITH' or 'John Doe SMITH' where each forename starts with a capital and the surname is in upper case. I have a crude method of scanning for the capitals and splitting this to give me an array of name segments with [0] as the Surname and a variable number of Forenames, but is there an 'elegant' way via regex to extract this into an array?

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
On Sat, 2011-01-01 at 09:46 +0000, Lester Caine wrote:

> A slightly more complex problem than phone numbers ...
> 
> It is a sort of convention to use the format 'JohnDoeSMITH' or 'John Doe 
> SMITH' 
> where each forename starts with a capital and the surname is in upper case. I 
> have a crude method of scanning for the capitals and splitting this to give 
> me 
> an array of name segments with [0] as the Surname and a variable number of 
> Forenames, but is there an 'elegant' way via regex to extract this into an 
> array?
> 
> -- 
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php
> 


I wouldn't try and do this with a regex, it would just become too
complicated. What about people with no middle name, or multiple middle
names? How do you deal with double-barrelled names like John
Walter-Smythe Doe? You would be far better off using multiple input
boxes for this sort of thing, and then format it as required when
outputting the data.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---

Reply via email to