Re: Re: Regular Expression
| From: | Kelly Hallman | Date: | Mon, 19 Apr 2004 06:10:04 +0000 |
| Subject: | Re: Re: Regular Expression | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-33952@lists.php.net to get a copy of this message | ||
Apr 18 at 11:01pm, Andy Ladouceur wrote:
> Andy Amol wrote:
> > I would like to test whether a given sting contains only character, it
> > should also support spaces. eg "Course Book String". I am able to test
> > "CourseBookString". Also I would like to know how can we avoid wild
> > chars like *, or any other char apart from alpha numeric char.
>
> A regexp like this should work:
> /^([a-zA-Z]|\s)+$/
/^[A-Za-z\s]+$/ would be a better way of putting it.
however, \s would match tabs (also CR and/or LF in some regex engines).
to only alpha or space, this would work best:
/^[A-Za-z ]+$/
--
Kelly Hallman