> Code snippet ->
>
> header('Content-type: text/plain');
>
> $foo = ' ';
>
> echo "$foo\n";
>
>
> $path = '../../../';
> $bar = preg_replace('/()/', "$1" . $path . "$2",
$foo);
>
> echo $bar;
It's being greedy. Your pattern is matching
( )
and inserting $path between the two.
Use
$bar = preg_replace('/()/U',"$1" . $path . "$2", $foo);
Quote:
U (PCRE_UNGREEDY)
This modifier inverts the "greediness" of the quantifiers so that they
are not greedy by default, but become greedy if followed by "?". It is
not compatible with Perl. It can also be set by a (?U) modifier setting
within the pattern.
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php