PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Re: [PHP] Re: Re[PHP] gex to catch <p>s
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: [PHP] Re: Re[PHP] gex to catch <p>s

Réponse
 
LinkBack Outils de la discussion
Vieux 07/05/2008, 18h51   #1
Ryan S
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Re: Re[PHP] gex to catch <p>s




Hey,

<clip>
$tag_regex=array(
'/\<p(\s*)\>(.*?)\<\/p\> /si' => "$1",
'/\<(\s*)(*.?)class\=(*.?)\>(.*?)\<\/(*.?)\>/si' => "$3"
);

$paragraphs=preg_replace(array_keys($tag_regex),ar ray_values($tag_regex),$page);

I am not sure what tag is that you mean on <class="something">, but in this
RE .. it should capture any <p> tags (the first element of the array) and
any tags (the second element of the array) that has attribute class on it.
</clip>

Thanks for replying!
Sorry, a bit of a typo there, i meant <p class="something">

I ran your regex but got this warning:
Warning: preg_replace() [function.preg-replace]: Compilation failed: nothing to repeat at offset 8 in C:\xampp2\htdocs\ezee\tests\para_regex.php on line 25


I think I ran it wrong, because although i have passed $page i dont know where to pass the replacement texts...

Can you give me an example on how to run this or an explanation?

Thanks!
R



__________________________________________________ __________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i...Dypao8Wcj9tAcJ
  Réponse avec citation
Vieux 08/05/2008, 18h13   #2
smulyono
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Re: Re[PHP] gex to catch <p>s

If you mean <p class='something'></p> then this should be okay:

$tag_regex=array(
'/\<p\>(.*?)\<\/p\> /si' => "$1",
'/\<p(\s*)class\=(*.?)\>(.*?)\<\/p\>/si' => "$2"
);
$paragraphs=preg_replace(array_keys($tag_regex),ar ray_values($tag_regex),$pa
ge);

$paragraphs will be the return value
$page is the text with all of the tags that you want to stripped

If you want, you can try the first value in the array first which detect the
<p></p>. I didn't test this, but this should be working since I also use
this kind of way to revert the phpbb code into HTML.

HTH,

Thanks,


-----Original Message-----
From: Ryan S [mailto:genphp@yahoo.com]
Sent: Wednesday, May 07, 2008 10:52 AM
To: vester_s
Cc: php php
Subject: Re: [php] Re: Re[php] gex to catch <p>s




Hey,

<clip>
$tag_regex=array(
'/\<p(\s*)\>(.*?)\<\/p\> /si' => "$1",
'/\<(\s*)(*.?)class\=(*.?)\>(.*?)\<\/(*.?)\>/si' => "$3"
);

$paragraphs=preg_replace(array_keys($tag_regex),ar ray_values($tag_regex),$pa
ge);

I am not sure what tag is that you mean on <class="something">, but in this
RE .. it should capture any <p> tags (the first element of the array) and
any tags (the second element of the array) that has attribute class on it.
</clip>

Thanks for replying!
Sorry, a bit of a typo there, i meant <p class="something">

I ran your regex but got this warning:
Warning: preg_replace() [function.preg-replace]: Compilation failed:
nothing to repeat at offset 8 in C:\xampp2\htdocs\ezee\tests\para_regex.php
on line 25


I think I ran it wrong, because although i have passed $page i dont know
where to pass the replacement texts...

Can you give me an example on how to run this or an explanation?

Thanks!
R




__________________________________________________ __________________________
________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

  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 17h24.


É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,09933 seconds with 10 queries