[PHP] Re: [PHP-DB] Re: [PHP] Regex for telephone numbers

2010-12-30 Thread Daniel Brown
On Thu, Dec 30, 2010 at 14:07, Ethan Rosenberg eth...@earthlink.net wrote: Josh - I used use \d{3}-\d{3}-\d{4}. It works beautifully!! Just keep in mind that invalid numbers will also pass that check, such as 000-000- or 123-456-6789. That's why my example was a bit more involved.

[PHP] Re: [PHP-DB] Re: [PHP] Regex for telephone numbers

2010-12-29 Thread Karl DeSaulniers
Hi Ethan, Could you do a string compare and check at certain characters for a dash? IE: check the second character to see if it is a dash for 1-800... if that is not a dash, check the fourth character for a dash, 469-9... then the other places where dashes would be based on those two

[PHP] Re: [PHP-DB] Re: [PHP] Regex for telephone numbers

2010-12-29 Thread Karl DeSaulniers
You could also help them out a little with something like.. $phone = str_replace((, , $phone); $phone = str_replace(), -, $phone); HTH, Karl On Dec 29, 2010, at 6:27 PM, Josh Kehn wrote: On Dec 29, 2010, at 7:12 PM, Ethan Rosenberg eth...@earthlink.net wrote: Dear List - Thank you

Re: [PHP] Re: [PHP-DB] Re: [PHP] Regex for telephone numbers

2010-12-29 Thread Alexis
Why not have three separate fields for each part, as that way you don't need to bother about how the user separates them, as trust me, if they can break it, they will. I have found it is best to always limit the amount of free entry you permit a user, as that will drastically cut back in data