At 9:47 PM -0800 3/31/01, Chris Adams <[EMAIL PROTECTED]> wrote:
>On 31 Mar 2001 21:07:59 -0800, Michael Hall <[EMAIL PROTECTED]> wrote:
>>
>>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.
>
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 |
| [EMAIL PROTECTED] Computer Consultant |
| http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |
+-------------------------- www.yurisnight.net --------------------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]