Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

/proc/kallsyms format, sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas

Links

XODOX
Impressum

#1: A simple preg_replace escaping problem

Posted on 2008-04-24 20:42:10 by cronoklee

Hi I'm having trouble running the following preg_replace:

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

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

Cheers,
Ciar=E1n

Report this message

#2: Re: A simple preg_replace escaping problem

Posted on 2008-04-24 20:52:47 by Paul Lautman

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

Take a look at preg_quote()

Report this message

#3: Re: A simple preg_replace escaping problem

Posted on 2008-04-24 21:14:38 by cronoklee

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

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


Ah! Very handy! Thanks a lot!

Report this message

#4: Re: A simple preg_replace escaping problem

Posted on 2008-04-24 23:49:02 by Paul Lautman

Ciaran wrote:
> On Apr 24, 7:52 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> wrote:
>> Ciaran wrote:
>> > Hi I'm having trouble running the following preg_replace:
>>
>> > $thestring = preg_replace( '!<a
>> > href="javascript:radio(&#39;/0radio/
>> > stream.php?radioID=(.*?)&#39;)" class="radioPlay">(.*?)</a>!' ,
>> > "[radio:\\1]", $thestring );
>>
>> > Can anyone help me escape the &#39; apostrophe? I've tried all
>> > combinations of \ in front of the &#39; 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.

Report this message