Jim Lucas | 1 Jan 2011 01:09

Re: Regex for telephone numbers

On 12/29/2010 4:35 PM, Daniel P. Brown wrote:
> On Wed, Dec 29, 2010 at 19:12, Ethan Rosenberg <ethros <at> earthlink.net> wrote:
>> Dear List -
>>
>> Thank you for all your help in the past.
>>
>> Here is another one....
>>
>> I would like to have a regex  which would validate that a telephone number
>> is in the format xxx-xxx-xxxx.
> 
>     Congrats.  People in Hell would like ice water.  Now we all know
> that everyone wants something.  ;-P
> 
>     Really, this isn't a PHP question, but rather one of regular
> expressions.  That said, something like this (untested) should work:
> 
> <?php
> 
> $numbers = array(
>         '123-456-7890',
>         '2-654-06547',
>         'sf34-asdf-',
>         'abc-def-ghij',
>         '555_555_5555',
>         '000-000-0000',
>         '8007396325',
>         '241-555-2091',
>         '800-555-0129',
>         '900-976-739',
(Continue reading)

Lester Caine | 1 Jan 2011 10:46
Picon
Favicon
Gravatar

Regex for ... genealogical names

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

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Ashley Sheridan | 1 Jan 2011 15:36
Picon

Re: Regex for ... genealogical names

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
(Continue reading)

Al | 1 Jan 2011 15:46
Favicon

Re: Regex for ... genealogical names


On 1/1/2011 4:46 AM, Lester Caine wrote:
> JohnDoeSMITH' or 'John Doe SMITH'

Try this. not tested.

First, which adds spaces as needed. e.g. JohnDoeSMITH > 'John Doe SMITH'

$newName=preg_replace("%(?<=[a-z])([A-Z])", " $1", $name);//Cap following low
case, add space before it

Next, alphas following a cap, lower case them

function lowCase($matches){return strtolower($matches[1]);}

$newName= preg_replace_callback("%(?<=[A-Z])([A-Z])%", "lowCase', $newName);

Sorry don't have time today to test; but, this should get you started.

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Adolfo Olivera | 2 Jan 2011 01:36
Picon

Newbie Question

Hi,
    I'm new for php. Just trying to get my hello  world going on godaddy
hosting. Can't getting to work. I think sintax it's ok. I was understanding
that my shared hosting plan had php installed. Any suggestions. Thanks,

Happy 2011!!

PS: Please, feel free to educate me on how to address the mailing list,
since again, I'm new to php and not a regular user of mailing lists,
Joshua Kehn | 2 Jan 2011 01:39
Picon
Gravatar

Re: Newbie Question

On Jan 1, 2011, at 7:36 PM, Adolfo Olivera wrote:

> Hi,
>    I'm new for php. Just trying to get my hello  world going on godaddy
> hosting. Can't getting to work. I think sintax it's ok. I was understanding
> that my shared hosting plan had php installed. Any suggestions. Thanks,
> 
> Happy 2011!!
> 
> PS: Please, feel free to educate me on how to address the mailing list,
> since again, I'm new to php and not a regular user of mailing lists,

Can you post the code that you are using?

It should look something like the following:

<?php echo "Hello World!"; ?>

Regards,

-Josh
____________________________________
Joshua Kehn | Josh.Kehn <at> gmail.com
http://joshuakehn.com

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

(Continue reading)

David Robley | 2 Jan 2011 01:50
Picon

Re: Newbie Question

Joshua Kehn wrote:

> On Jan 1, 2011, at 7:36 PM, Adolfo Olivera wrote:
> 
>> Hi,
>>    I'm new for php. Just trying to get my hello  world going on godaddy
>> hosting. Can't getting to work. I think sintax it's ok. I was
>> understanding that my shared hosting plan had php installed. Any
>> suggestions. Thanks,
>> 
>> Happy 2011!!
>> 
>> PS: Please, feel free to educate me on how to address the mailing list,
>> since again, I'm new to php and not a regular user of mailing lists,
> 
> 
> Can you post the code that you are using?
> 
> It should look something like the following:
> 
> <?php echo "Hello World!"; ?>
> 

And normally would need to be saved as a .php file so the contents will be
handled by php.

Cheers
--

-- 
David Robley

(Continue reading)

Joshua Kehn | 2 Jan 2011 01:55
Picon
Gravatar

Re: Newbie Question

On Jan 1, 2011, at 7:50 PM, David Robley wrote:
> 
> And normally would need to be saved as a .php file so the contents will be
> handled by php.
> 
> 
> Cheers
> -- 
> David Robley
> 
> A fool and his money are my two favourite people.
> Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. 

Save the code as hello.php. Copy it to your root web directory (should be the base directory or something
called public_html / www when you FTP in) and access it from youdomain.com/hello.php

Regards,

-Josh
____________________________________
Joshua Kehn | Josh.Kehn <at> gmail.com
http://joshuakehn.com

Adolfo Olivera | 2 Jan 2011 02:37
Picon

Re: Newbie Question

Sorry, here is the code. The .php extension is a requirement? Can't it b
embedded on a .html file?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="
http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type"
content="text/html; charset=utf-8" /> <title>Untitled Document</title>
</head> <body> <?php $a = "hello"; $hello ="Hello Everyone"; echo $a; echo
$hello; ?> </body> </html>
On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn <josh.kehn <at> gmail.com> wrote:

> On Jan 1, 2011, at 7:50 PM, David Robley wrote:
> >
> > And normally would need to be saved as a .php file so the contents will
> be
> > handled by php.
> >
> >
> > Cheers
> > --
> > David Robley
> >
> > A fool and his money are my two favourite people.
> > Today is Boomtime, the 2nd day of Chaos in the YOLD 3177.
>
> Save the code as hello.php. Copy it to your root web directory (should be
> the base directory or something called public_html / www when you FTP in)
> and access it from youdomain.com/hello.php
>
> Regards,
(Continue reading)

Joshua Kehn | 2 Jan 2011 02:39
Picon
Gravatar

Re: Newbie Question

On Jan 1, 2011, at 8:37 PM, Adolfo Olivera wrote:

> Sorry, here is the code. The .php extension is a requirement? Can't it b embedded on a .html file?
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>Untitled Document</title>
> 
> </head>
> <body>
> <?php
> $a = "hello";
> $hello ="Hello Everyone";
> echo $a;
> echo $hello;
> ?>
> </body>
> </html>
> 
> On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn <josh.kehn <at> gmail.com> wrote:
> On Jan 1, 2011, at 7:50 PM, David Robley wrote:
> >
> > And normally would need to be saved as a .php file so the contents will be
> > handled by php.
> >
> >
> > Cheers
(Continue reading)


Gmane