Beauford wrote: > ... >>> function invalidchar($strvalue) >>> { >>> if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { >> That regexp matches if $strvalue consists of zero or more >> ocurrences of a letter, a whitespace character, and any >> character whose numeric value lies between the numeric values >> of "'" and "." in your locale. >> Zero or more means it also matches an empty string. >> >> .. > > Further to my previous email, there is something weird going on here. I just > tried using this: > > if (!ereg('^[A-Za-z0-9]', $strvalue)) { > return "error"; > } stop using bleeding ereg*() function - move to preg_*() funcs like the rest of the world did 5+ years ago. > > When I enter the word Test, which is valid, I am still getting an error 'Test' is not valid according to the regexp your using. <?php $strs = array("Test", "Jochem", "@##^%", "", "Test1", "Test!", "J*nk"); // match a non-empty string containing *only* alpha numeric chars foreach ($strs as $s) { if (!preg_match("#^[A-Z0-9]+\$#i", $s)) { echo "error in string: \"$s\" \n"; } else { echo "no problemo: \"$s\" \n"; } } ?> (ps the above is a crappy regexp for real world use imho, but it serves the purpose of example) you need to read up and do lots of practicing with regexps - we do realise that regexps are not easy, unfortunately there is no shortcut to learning how to use them. I doubt many on this list could be considered expert in the field of regexps, but you have to get yourself a basic grasp or these things will bite you in the ass until the cows come home. start here: http://php.net/pcre http://php.net/manual/en/reference.pcre.pattern.modifiers.php http://php.net/manual/en/reference.pcre.pattern.syntax.php > returned - but only on this one page. So there has got to be something on > this page that is screwing this up, but what. I have been over and over this > and can't see a problem. > > I could really use another pair of eyes on this as it is driving me nuts. I regexps drives everyone nuts to start with. first there is only the mountain, then the mountain is not a mountain, finally there is just mountain. > am now into hour 6 with this. Absolutely ridiculous. thats nothing. most people take months to get anywhere useful with regexps, well okay I'm speaking for myself - I was in your position somewhere back in 2001, I was regularly sweating it for weeks trying to understand and getting certain regexps work 'properly'. don't give up. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php