> I get the following error: > > Parse error: parse error, expecting `T_VARIABLE' or `'$'' in > /usr/local/apache/htdocs/lib/lib_string.inc on line 218 > > Using this code: > $str = > preg_replace("!([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])!ei", "<a > href=\"{$1}://{$2}{$3}\">{$2}{$3}</a>", $str);
Since you're using the 'e' modifier, the "replacement" string needs to be valid PHP code. So, it should start with a variable or a function. A replacement such as: 'print("<a href="{$1} .. ")' should work. I didn't get a chance to answer you original question. I couldn't even get that regular expression to match links in any tests that I did, but if it's working for you, that's good. Couldn't you modify the expression to look for 0-60 characters that are not a space, followed by any amount of characters that are not a space, and only actually match the first 0-60 to use in your replacement string? Something like: ([^[:space:]]{0,60})[^[:space:]]* Which will match up to 60 characters in $2 for example, and also allow form more characters than that, but just not match them. This is assuming what everyone else said is right and you fix the entire regex to match the preg syntax... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php