Re: Ereg problems
| From: | Daniel Anderson | Date: | Tue, 16 Jan 2007 18:49:36 +0000 |
| Subject: | Re: Ereg problems | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-27394@lists.php.net to get a copy of this message | ||
Then I think this will do the trick for you :)
--------------------------------------------------------------------------------
$string = "~YOUR STRING~"
if (!eregi_replace("[0-9A-Za-z -_']","",$string))
{
echo "string allowed";
}
else {
echo "string disallowed";} -------------------------------------------------------------------------------- Warmest Regards, Dan ----- Original Message ----- From: "Beauford" <phpuser@netscan.ca> To: <php-windows@lists.php.net> Sent: Tuesday, January 16, 2007 5:59 PM Subject: RE: [PHP-WIN] Ereg problems
No, this is what I said in my original email. I want to allow the following: a to z, A to Z, 0 to 9, and "_-'" (without the double quotes) and spaces. I don't care about length, I don't care about order. I just want the user to be able to use these characters. A to z A to Z 0 to 9 and the character _-' and spaces. So ABCDE __-' is valid, so is _-aaaBBcD' __ Thanks-----Original Message----- From: Niel Archer [mailto:Niel Archer] On Behalf Of Niel Archer Sent: January 16, 2007 11:46 AM To: php-windows@lists.php.net Subject: Re: [PHP-WIN] Ereg problems Hi What you've written doesn't match the description you gave. As a regular expression "([0-9][A-Z][a-z][-_.'\ ])" means a digit followed by an uppercase letter followed by a lower case letter followed by (hyphen or underscore or mid-dot or single quote or space). This is a total of four characters only. Is your string only supposed to be four characters in that format? I had assumed from your original post, that you wanted a variable length string, that could only contain alphanumeric characters plus hyphen, underscore, and single quote (I missed the space). All of which in any position. If this is not the case please describe exactly what it is you're trying to achieve. Niel -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php