Re: Simple RegExp Problem...

From: Date: Fri, 22 Nov 2002 13:18:53 +0000
Subject: Re: Simple RegExp Problem...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-125604@lists.php.net to get a copy of this message
At 13:38 22.11.2002, @ Nilaab spoke out and said: --------------------[snip]-------------------- >Ok, I know this is easy for most of you, and believe me I've been searching >and trying to learn all about regular expressions, but I can't seem figure >out how to allow addition of spaces between characters. > >$text = "Here is some text"; > >Here, I want to be able to match the alpha characters as well as the spaces >in between each word. So far I have: > >preg_match("/^[a-zA-Z]+$/", $text); > >But that only matches a single word without spaces. I would like to try to >stay away from ereg and use preg_match instead because I heard preg_match is >faster. ereg() has a way to match spaces by specifying [[:space:]], but I >didn't get that solution to work either. How do I match $text to return >true? --------------------[snip]-------------------- use preg_match('/^[a-zA-Z\s]+$/', $text); \s - any [:space:] \S - anything not [:space:] -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#125604) next »