Re: Regular expression problems
| From: | Chris Hayes | Date: | Mon, 14 Apr 2003 16:01:56 +0000 |
| Subject: | Re: Regular expression problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143800@lists.php.net to get a copy of this message | ||
At 17:58 14-4-03, you wrote:
else if (eregi("^[a-zA-Z0-9!@#\$%^&\*\(\),/.//<>\?;':\"~`_\+\|\\-\\t\n\ ]*$", $sessname)) and what's that /.// part?
Hm. I am not sure about the escapes in this list. I am the trial and error type. * I'm not sure whether the ^ within the [] is read as the character ^ or as NOT (here: ^& could be read as not & ??). * You are writing \\t, i assume to allow tabs ("\t"), but next to that you have \n in stead of \\n to allow newlines ("\n"). Test to see whether or not this works as intended. There is some general whitespace term, check the docs * i see you are using \\- as well, why is this ? Withing [] this hyphen will be read as a connector like with a-z, so you do need one escape but i see no reason to use two escapes which effectively ens up in allowing: \-. This could be your problem. I do not know whether \- means something like \t and \n, but i think not. Try a single slash \- (so here: \|\-\\t\\n. * check in the docs or by testing whether or not you need to escape & * sometimes you need to double escape the $, i forgot why exactly. check the history of this group on www.php.net for \\&. What is the slash after \n for? Is there a space after that? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php