PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > Regular Expression replacement
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Regular Expression replacement

Réponse
 
LinkBack Outils de la discussion
Vieux 06/11/2007, 16h40   #1
hol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Regular Expression replacement

Hello,

I want to replace all accurences of the substring
width:000px (where 000 is any 3 digit number)
with the string
width:800px.

For example the following string :
style="width:400px; height:326px;" id="VideoPlayback"
type="application/x-shockwave-flash"
should be changed to
style="width:800px; height:326px;" id="VideoPlayback"
type="application/x-shockwave-flash"

so I used the following command :
$pvid = str_replace("width:[1-9][0-9][0-9]px","width:800px",$pvid) ;

but it does not seem to work.

Any ideas on this?

Thnaks beforehand.


  Réponse avec citation
Vieux 06/11/2007, 19h15   #2
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Regular Expression replacement


"hol" <contact7@hol.gr> wrote in message
news:fgq5d0$e6d$1@newsmaster.pub.dc.hol.net...
> Hello,
>
> I want to replace all accurences of the substring
> width:000px (where 000 is any 3 digit number)
> with the string
> width:800px.
>
> For example the following string :
> style="width:400px; height:326px;" id="VideoPlayback"
> type="application/x-shockwave-flash"
> should be changed to
> style="width:800px; height:326px;" id="VideoPlayback"
> type="application/x-shockwave-flash"
>
> so I used the following command :
> $pvid = str_replace("width:[1-9][0-9][0-9]px","width:800px",$pvid) ;
>
> but it does not seem to work.
>
> Any ideas on this?


/width\s*?:\s*?\d{1,3}px/i


  Réponse avec citation
Vieux 06/11/2007, 21h38   #3
hol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Regular Expression replacement

Thanks for your reply Steve.

I tried what you suggested
$pvid = str_replace(" /width\s*?:\s*?\d{1,3}px/i","width:800px",$pvid) ;
but unfortunatelly did not work.




Ï "Steve" <no.one@example.com> Ýãñáøå óôï ìÞíõìá
news:K23Yi.56$zj4.25@newsfe02.lga...
>
> "hol" <contact7@hol.gr> wrote in message
> news:fgq5d0$e6d$1@newsmaster.pub.dc.hol.net...
>> Hello,
>>
>> I want to replace all accurences of the substring
>> width:000px (where 000 is any 3 digit number)
>> with the string
>> width:800px.
>>
>> For example the following string :
>> style="width:400px; height:326px;" id="VideoPlayback"
>> type="application/x-shockwave-flash"
>> should be changed to
>> style="width:800px; height:326px;" id="VideoPlayback"
>> type="application/x-shockwave-flash"
>>
>> so I used the following command :
>> $pvid = str_replace("width:[1-9][0-9][0-9]px","width:800px",$pvid) ;
>>
>> but it does not seem to work.
>>
>> Any ideas on this?

>
> /width\s*?:\s*?\d{1,3}px/i
>



  Réponse avec citation
Vieux 07/11/2007, 14h03   #4
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Regular Expression replacement


"hol" <contact7@hol.gr> wrote in message
news:fgqmsv$u8d$1@newsmaster.pub.dc.hol.net...
> Thanks for your reply Steve.
>
> I tried what you suggested
> $pvid = str_replace(" /width\s*?:\s*?\d{1,3}px/i","width:800px",$pvid) ;
> but unfortunatelly did not work.


i just used:

/width\s*?:\s*?\d{1,3}px\s*?;?/i

as the pattern, this as the string to search:

width:400px; height:326px;" id="VideoPlayback"

and this as the replacement:

width:800px;

and i got this as the result:

width:800px; height:326px;" id="VideoPlayback"

seems to work for me. sorry it does not for you.


  Réponse avec citation
Vieux 07/11/2007, 14h05   #5
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Regular Expression replacement


"hol" <contact7@hol.gr> wrote in message
news:fgqmsv$u8d$1@newsmaster.pub.dc.hol.net...
> Thanks for your reply Steve.
>
> I tried what you suggested
> $pvid = str_replace(" /width\s*?:\s*?\d{1,3}px/i","width:800px",$pvid) ;
> but unfortunatelly did not work.


btw, look at the replacement string above. it starts with " /width"...note
the space. that may make a difference.


  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 18h41.


Édité par : vBulletin® version 3.7.3
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 ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12826 seconds with 13 queries