RE: [PHP] eregi_replace() function in a script

From: Date: Sun, 01 Dec 2002 18:13:06 +0000
Subject: RE: [PHP] eregi_replace() function in a script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-126623@lists.php.net to get a copy of this message
> The script works fine but I have a question with the following line: > > $Pattern="(http://)([^[:space:]]+) ([[:alnum:]\.,-?/&=])"; // The variable > $Pattern is declared with three groupings. > > My question: > If the user inadvertantly inputs a *space* _after_ the http:// grouping > and > _before_ the www. grouping my understanding is that would not be valid > from > the $Pattern match due to: > ................ > ([^[:space:]]+) > .................. > > Correct? Yes, that's correct. That piece of the pattern matches anything that's not a space, one or more times. > I tried the script by putting a space before the URL and the PHP still > processes the data with no error. A space before everything is fine, as the pattern will match the remainder of the string. If you put a ^ at the very beginning of the pattern, that'll mean the beginning of the string must be followed by (http), so then a space will cause the patter match to fail. ---John Holmes...

« previous php.general (#126623) next »