Page 1 of 1
ereg in php5.1.4
Posted: Fri May 12, 2006 8:38 pm
by Charles256
Code: Select all
if (ereg("[^:space:a-zA-Z0-9\.]",$author2))
{
echo 'Only use spaces, periods, and alhpa numeric charecters.';
$error=1;
}
this works fine if the variable has alpha numeric and periods but as soon as I throw in a space it goes haywire, any ideas why?
Posted: Sun May 14, 2006 1:43 am
by Charles256
noone?
Posted: Sun May 14, 2006 1:47 am
by Burrito
Moved to Regex.
Wish I could help, but I don't know much about the posix engine... would be easy to do in PCRE

Posted: Sun May 14, 2006 4:45 am
by Charles256
hell,i'll take any example of how to do it with any function

Posted: Sun May 14, 2006 5:06 am
by $phpNut
this might not work, but try '\s' rather than :space: ...
Posted: Sun May 14, 2006 7:17 am
by Oren
You can use: \s as $phpNut said, but this will allow new lines and tabs and not just spaces. Is that ok?
Posted: Sun May 14, 2006 3:09 pm
by Charles256
yep.it is.thanks a ton

I'll test it in a minute.
Posted: Sun May 14, 2006 7:52 pm
by Charles256
Code: Select all
if (ereg("[^\sa-zA-Z0-9\.]",$author2))
{
echo 'Only use spaces, periods, and alhpa numeric charecters.';
$error=1;
}
that doesn't work either... : sigh : it worked in php4..why not php5.1.4

Posted: Sun May 14, 2006 8:15 pm
by feyd
[:space:] is the macro in Posix, I believe, but why use it when PCRE is faster and will be supported in future versions of php where Posix won't?