A simple preg_replace escaping problem

Hi I'm having trouble running the following preg_replace:

$thestring =3D preg_replace( '!<a href=3D"javascript:radio('/0radio/
stream.php?radioID=3D(.*?)')" class=3D"radioPlay">(.*?)</a>!' ,
"[radio:\\1]", $thestring );

Can anyone help me escape the ' apostrophe? I've tried all
combinations of \ in front of the ' characters but nothing seems
to work.

Cheers,
Ciar=E1n
cronoklee [ Do, 24 April 2008 20:42 ] [ ID #1949448 ]

Re: A simple preg_replace escaping problem

Ciaran wrote:
> Hi I'm having trouble running the following preg_replace:
>
> $thestring = preg_replace( '!<a href="javascript:radio('/0radio/
> stream.php?radioID=(.*?)')" class="radioPlay">(.*?)</a>!' ,
> "[radio:\\1]", $thestring );
>
> Can anyone help me escape the ' apostrophe? I've tried all
> combinations of \ in front of the ' characters but nothing seems
> to work.
>
> Cheers,
> Ciarán

Take a look at preg_quote()
Paul Lautman [ Do, 24 April 2008 20:52 ] [ ID #1949449 ]

Re: A simple preg_replace escaping problem

On Apr 24, 7:52 pm, "Paul Lautman" <paul.laut... [at] btinternet.com>
wrote:
> Ciaran wrote:
> > Hi I'm having trouble running the following preg_replace:
>
> > $thestring =3D preg_replace( '!<a href=3D"javascript:radio('/0radio/=

> > stream.php?radioID=3D(.*?)')" class=3D"radioPlay">(.*?)</a>!' ,
> > "[radio:\\1]", $thestring );
>
> > Can anyone help me escape the ' apostrophe? I've tried all
> > combinations of \ in front of the ' characters but nothing seems
> > to work.
>
> > Cheers,
> > Ciar=E1n
>
> Take a look at preg_quote()


Ah! Very handy! Thanks a lot!
cronoklee [ Do, 24 April 2008 21:14 ] [ ID #1949452 ]

Re: A simple preg_replace escaping problem

Ciaran wrote:
> On Apr 24, 7:52 pm, "Paul Lautman" <paul.laut... [at] btinternet.com>
> wrote:
>> Ciaran wrote:
>> > Hi I'm having trouble running the following preg_replace:
>>
>> > $thestring = preg_replace( '!<a
>> > href="javascript:radio('/0radio/
>> > stream.php?radioID=(.*?)')" class="radioPlay">(.*?)</a>!' ,
>> > "[radio:\\1]", $thestring );
>>
>> > Can anyone help me escape the ' apostrophe? I've tried all
>> > combinations of \ in front of the ' characters but nothing
>> > seems to work.
>>
>> > Cheers,
>> > Ciarán
>>
>> Take a look at preg_quote()
>
>
> Ah! Very handy! Thanks a lot!

Although I always thought that preg_escape() would have been a better name.
Paul Lautman [ Do, 24 April 2008 23:49 ] [ ID #1949459 ]
PHP » comp.lang.php » A simple preg_replace escaping problem

Vorheriges Thema: How can I transmit an FLV video to a browser?
Nächstes Thema: No apxs when updating PHP