PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > A simple preg_replace escaping problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
A simple preg_replace escaping problem

Réponse
 
LinkBack Outils de la discussion
Vieux 24/04/2008, 19h42   #1
Ciaran
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut A simple preg_replace escaping problem

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 me escape the ' apostrophe? I've tried all
combinations of \ in front of the ' characters but nothing seems
to work.

Cheers,
Ciarán
  Réponse avec citation
Vieux 24/04/2008, 19h52   #2
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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 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()


  Réponse avec citation
Vieux 24/04/2008, 20h14   #3
Ciaran
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A simple preg_replace escaping problem

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('/0radio/
> > stream.php?radioID=(.*?)')" class="radioPlay">(.*?)</a>!' ,
> > "[radio:\\1]", $thestring );

>
> > Can anyone 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!
  Réponse avec citation
Vieux 24/04/2008, 22h49   #4
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A simple preg_replace escaping problem

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('/0radio/
>> > stream.php?radioID=(.*?)')" class="radioPlay">(.*?)</a>!' ,
>> > "[radio:\\1]", $thestring );

>>
>> > Can anyone 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.


  Réponse avec citation
Vieux 25/04/2008, 01h15   #5
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A simple preg_replace escaping problem

..oO(Paul Lautman)

>Ciaran wrote:
>> On Apr 24, 7:52 pm, "Paul Lautman" <paul.laut...@btinternet.com>
>> wrote:
>>
>>> 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.


function preg_escape($str, $delimiter = NULL) {
return preg_quote($str, $delimiter);
}

SCNR
Micha
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h40.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09144 seconds with 13 queries