Re: One last try at this!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Roman Neuhauser wrote:
# lists@xxxxxxxxx / 2007-01-17 17:02:12 -0800:
Beauford wrote:
	if(!preg_match("/^[-A-Za-z0-9_.' ]+$/", $string)) {
	return "Invalid Characters";
}	

In your regex you have a "."  this will match anything

try this:

<plaintext><?php

function ValidateString($string) {
	if ( preg_match("/[^a-zA-Z0-9\_\.\' -]+/", $string) ) {
		return "Invalid Characters";
	}
	return false;
}

That "." is inside a character class where it is a literal character
(matches only ".").  Why are you backslashing the underscore is beyond
me.

This is fine, is there any harm in escaping them?
The match will work either way right?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux