RE: [PHP] Re: preg_replace("/^\//".. doesnt work?
that's probably what he meant... but what he asked for was how to "replace the first '/' in $a" if you have $a="abc/def", the regex "^/" will not replace the first "/" in your string, which was my point :-) > -Original Message- > From: James Taylor [mailto:[EMAIL PROTECTED]] > Subject: Re: [PHP] Re: preg_replace("/^\//".. doesnt work? > > Err, that's what he wanted > > On Wednesday 20 February 2002 12:13 pm, you wrote: > > Also note: > > > > "^" matches the beginning of the string, so "^\/" > > will only match a "/" at the beginning of the > > string (not the first occurence of "/") > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: preg_replace("/^\//".. doesnt work?
Err, that's what he wanted On Wednesday 20 February 2002 12:13 pm, you wrote: > Also note: > > "^" matches the beginning of the string, so "^\/" > will only match a "/" at the beginning of the > string (not the first occurence of "/") > > > -Original Message- > > From: Philip Hallstrom [mailto:[EMAIL PROTECTED]] > > Subject: [PHP] Re: preg_replace("/^\//".. doesnt work? > > > >$a = "/test/"; > >$a = preg_replace("/^\//", "", $a); > >echo $a; > > > > On Wed, 20 Feb 2002, John Ericson wrote: > > > 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? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: preg_replace("/^\//".. doesnt work?
Also note: "^" matches the beginning of the string, so "^\/" will only match a "/" at the beginning of the string (not the first occurence of "/") > -Original Message- > From: Philip Hallstrom [mailto:[EMAIL PROTECTED]] > Subject: [PHP] Re: preg_replace("/^\//".. doesnt work? > >$a = "/test/"; >$a = preg_replace("/^\//", "", $a); >echo $a; > > On Wed, 20 Feb 2002, John Ericson wrote: > > > > 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? > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: preg_replace("/^\//".. doesnt work?
thanks! On Feb 20 11:55, Philip Hallstrom wrote: >$a = "/test/"; >$a = preg_replace("/^\//", "", $a); >echo $a; > > Notice the difference in the second line... > > On Wed, 20 Feb 2002, John Ericson 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. > > > > -- > > * 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 > > -- * 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] Re: preg_replace("/^\//".. doesnt work?
$a = "/test/"; $a = preg_replace("/^\//", "", $a); echo $a; Notice the difference in the second line... On Wed, 20 Feb 2002, John Ericson 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. > > -- > * 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