Reply to Re: [PHP] preg_match - help please

Your name:

Reply:


Posted by John Nichel on 11/14/58 11:22

Steve Turnbull wrote:
> Hi
>
> I want to see that a user is submiting a form field in the correct manner.
> So I decided to use preg_match to verify their input.
>
> The pattern I am trying to match is;
>
> Firstname Secondname
>
> I am not bothered about character length just yet (but advise on this would
> be appreciated if it can be done with a regular expression - saves extra
> checking code), but I would like case sensitity.
>
> The code I haev so far, which doesn't seem to work is;
>
> $un = $_REQUEST['name'];
> $exp = '/^\b[a-zA-Z] [a-zA-Z]$/';
>
> if (preg_match($exp, $un)) {
> //has this matched?
> echo "<h2>matched</h2>";
> }
>
> Help would be greatly appreciated

/^[a-zA-Z]{1,}\s[a-zA-Z]{1,}$/

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@kegworks.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация