Re: ereg
| From: | Steve Edberg | Date: | Mon, 02 Apr 2001 00:17:16 +0000 |
| Subject: | Re: ereg | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-46533@lists.php.net to get a copy of this message | ||
At 9:47 PM -0800 3/31/01, Chris Adams <chris@improbable.org> wrote:
On 31 Mar 2001 21:07:59 -0800, Michael Hall <lists@mulga.com.au> wrote:If by 'spaces' you want to include tabs, newlines & stuff, you can also do: if (!ereg("^[[:alnum:][:space:]_-]+$", $string)) { get outta here! } -steve -- +----------- 12 April 2001: Forty years of manned spaceflight -----------+ | Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +-------------------------- www.yurisnight.net --------------------------+I'm using the following expression to check input strings: if (!ereg("^[[:alnum:]_-]+$", $string)) { get outta here! } This works fine except for when a string has spaces, as in text. What do I need to add to the expression to handle spaces (internal, not at the beginning or end).if (!ereg("^[[:alnum:]_- ]+$", $string)) { get outta here! } Check out the regular expression documentation or "Mastering Regular Expressions" over at ora.com.