RE: [PHP] preg_replace("/^\//".. doesnt work?

2002-02-20 Thread Darren Gamble

Good day,

The first argument should just be a normal regular expression, not a
replacement regular expression.

I'm not at my server right now, but I would guess that it'll work once you
get rid of the last / in the first expression.


Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948


-Original Message-
From: John Ericson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 20, 2002 1:25 PM
To: [EMAIL PROTECTED]
Subject: [PHP] preg_replace("/^\//".. doesnt work?


Im having a weird regexp problem in PHP that I think is correct but it
doesnt appear to work.

The code is this:

$a = "/test/";
preg_replace("/^\//", "", $a);
echo $a;

I want preg_replace to replace the first '/' in $a with '' so that the 
echo function echoes "test/", but instead it echoes "/test/" as if
preg_replace didnt worked? What am I doing wrong?

Im using:
PHP Version 4.1.1
Configure Command: './configure' '--with-mysql=/usr/local/mysql'
'--with-apxs=/usr/local/apache/bin/apxs' '--with-db2--disable-debug'
'--disable-static' '--enable-sockets' '--with-yp' '--with-zlib'
Regex Library: Bundled library enabled
PCRE (Perl Compatible Regular Expressions) Support: enabled
PCRE Library Version: 3.4 22-Aug-2000


Please CC me since Im not a member of this maillinglist.

-- 
* John Ericson [EMAIL PROTECTED]
* ICQ: 7325429 JID: [EMAIL PROTECTED]
* web: http://john.pp.se

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] preg_replace("/^\//".. doesnt work?

2002-02-20 Thread James Taylor

try:

$a = preg_replace("/^\//", "", $a);

On Wednesday 20 February 2002 12:25 pm, you wrote:
> Im having a weird regexp problem in PHP that I think is correct but it
> doesnt appear to work.
>
> The code is this:
>
>   $a = "/test/";
>   preg_replace("/^\//", "", $a);
>   echo $a;
>
> I want preg_replace to replace the first '/' in $a with '' so that the
> echo function echoes "test/", but instead it echoes "/test/" as if
> preg_replace didnt worked? What am I doing wrong?
>
> Im using:
> PHP Version 4.1.1
> Configure Command: './configure' '--with-mysql=/usr/local/mysql'
> '--with-apxs=/usr/local/apache/bin/apxs' '--with-db2--disable-debug'
> '--disable-static' '--enable-sockets' '--with-yp' '--with-zlib'
> Regex Library: Bundled library enabled
> PCRE (Perl Compatible Regular Expressions) Support: enabled
> PCRE Library Version: 3.4 22-Aug-2000
>
>
> Please CC me since Im not a member of this maillinglist.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php