Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> regexp pobieranie tagow html
deirathe
post
Post #1





Grupa: Zarejestrowani
Postów: 426
Pomógł: 32
Dołączył: 24.05.2007

Ostrzeżenie: (0%)
-----


Mam takiego stinga biggrin.gif
$tpl=
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Untitled Document</title>
  5. </head>
  6.  
  7. <ui:include file="sa.tpl" />
  8. <ui:cache time="3h">
  9. <ui:loop select="as">
  10. sds
  11. </ui:loop>
  12. </ui:cache>
  13.  
  14.  
  15. <ui:loop select="asd" max="4" step="2" >
  16. <ui:var select="mVar" />
  17. tekst<ui:loop select="aaaa"><ui:loop select="aaaa"><ui:loop select="aaaa">
  18. <ul>teskt<li>1</li></ul>
  19. <ui:loop select="aaaa">
  20. <ui:include file="sa.tpl" />
  21. </ui:loop></ui:loop>sdsfdsfs</ui:loop>
  22. </ui:loop>
  23. <ui:if test="mVar GT asd">
  24. tak
  25. </ui:if>
  26. <ui:include file="sa.tpl" />
  27.  
  28.  
  29. <ui:include file="sa.tpl" />
  30. <ui:loop select="as">
  31. sds<ui:include file="sa.tpl" />
  32. </ui:loop>
  33. </body>
  34. </html>


I kiedy wywołuje
  1. <?php
  2. $tag="loop";
  3. preg_match_all("#<ui:".$tag."([^<]*?)(/>|>(.*?)</ui:".$tag.">)#is",$tpl,$res);
  4. ?>

to dostaje
  1. <ui:loop select="asd" max="4" step="2" >
  2. <ui:var select="mVar" />
  3. tekst
  4. <ul>teskt<li>1</li></ul>
  5. <ui:loop select="aaaa">
  6.  
  7. </ui:loop>

zamiast
  1. <ui:loop select="asd" max="4" step="2" >
  2. <ui:var select="mVar" />
  3. tekst
  4. <ul>teskt<li>1</li></ul>
  5. <ui:loop select="aaaa">
  6.  
  7. </ui:loop>
  8. </ui:loop>

wie ktos jak zrobic zeby regexp pobieral tagi tak jak nalezy?

dobra rozwiazane
  1. <?php
  2. preg_match_all("#<ui:".$tag."([^<]*?)(/>|>(.*?)</ui:".$tag.">)#Uis",$tpl,$res);
  3. ?>


i chyba raczej nie dziala :/ jak ktos moze to prosilbym o pomoc

Ten post edytował deirathe 11.02.2008, 23:30:37


--------------------
Kawałek mojego blogu
Everything should be as simple as possible but not simpler.
A Einstein
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 12)
nowotny
post
Post #2





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

Ostrzeżenie: (0%)
-----


Zrób sobie tak:
  1. <?php
  2. preg_match_all("#<ui:".$tag."([^<]*?)(/>|>(.*?)</ui:".$tag.">s+</ui:".$tag.">)#is",$tpl,$res);
  3. ?>


Ten post edytował nowotny 11.02.2008, 21:34:37
Go to the top of the page
+Quote Post
deirathe
post
Post #3





Grupa: Zarejestrowani
Postów: 426
Pomógł: 32
Dołączył: 24.05.2007

Ostrzeżenie: (0%)
-----


niesety to nie dziala
bierze mi teraz zachlannie :/


--------------------
Kawałek mojego blogu
Everything should be as simple as possible but not simpler.
A Einstein
Go to the top of the page
+Quote Post
nowotny
post
Post #4





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

Ostrzeżenie: (0%)
-----


A dałeś tam sobie modifiera 'U'...?
Go to the top of the page
+Quote Post
deirathe
post
Post #5





Grupa: Zarejestrowani
Postów: 426
Pomógł: 32
Dołączył: 24.05.2007

Ostrzeżenie: (0%)
-----


tez sprawdzalem z U i bez U i to samo ;/


--------------------
Kawałek mojego blogu
Everything should be as simple as possible but not simpler.
A Einstein
Go to the top of the page
+Quote Post
nowotny
post
Post #6





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

Ostrzeżenie: (0%)
-----


Takie coś mi działa... nie wiem czy ci będzie odpowiadać...
  1. <?php
  2. preg_match_all("#<ui:".$tag." select=\".+\" max=\".+\" step=\".+\".+</ui:".$tag.">s+</ui:".$tag.">#Uis",$tpl,$res);
  3. ?>
Go to the top of the page
+Quote Post
deirathe
post
Post #7





Grupa: Zarejestrowani
Postów: 426
Pomógł: 32
Dołączył: 24.05.2007

Ostrzeżenie: (0%)
-----


no tak ale wrzuciles tu juz atrybuty a w niektorych tagach wogole ich nie bedzie albo beda inne :/ zupdatowalem stringa zeby bylo wiadomo o co chodzi

Ten post edytował deirathe 11.02.2008, 23:31:03


--------------------
Kawałek mojego blogu
Everything should be as simple as possible but not simpler.
A Einstein
Go to the top of the page
+Quote Post
nowotny
post
Post #8





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

Ostrzeżenie: (0%)
-----


Czyli rozumiem że chcesz dopasować te wszystkie tagi najwyższego poziomu, tak...? razem z zawartymi w nich innymi tagami...? Zobacz czy to cię zadowala:
  1. <?php
  2. preg_match_all("#<ui:([a-zA-Z]+) .+(/>|</ui:1>)#Uis",$tpl,$res);
  3. ?>
Go to the top of the page
+Quote Post
deirathe
post
Post #9





Grupa: Zarejestrowani
Postów: 426
Pomógł: 32
Dołączył: 24.05.2007

Ostrzeżenie: (0%)
-----


Nie zebym byl niewdzieczny ale to nie dziala;/ pobiera tagi otwierajace i tylko do pierwszego tagu zamykajacego

Wydaje mi się że w regexp tego nie można zrobić


--------------------
Kawałek mojego blogu
Everything should be as simple as possible but not simpler.
A Einstein
Go to the top of the page
+Quote Post
nowotny
post
Post #10





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

Ostrzeżenie: (0%)
-----


U mnie działa... :/
Go to the top of the page
+Quote Post
deirathe
post
Post #11





Grupa: Zarejestrowani
Postów: 426
Pomógł: 32
Dołączył: 24.05.2007

Ostrzeżenie: (0%)
-----


a sprawdzales z tym przykladem co go poprawilem? z tym u gory? dzieki z gory


--------------------
Kawałek mojego blogu
Everything should be as simple as possible but not simpler.
A Einstein
Go to the top of the page
+Quote Post
nowotny
post
Post #12





Grupa: Zarejestrowani
Postów: 875
Pomógł: 122
Dołączył: 2.02.2008

Ostrzeżenie: (0%)
-----


Cytat(deirathe @ 12.02.2008, 14:30:23 ) *
a sprawdzales z tym przykladem co go poprawilem? z tym u gory? dzieki z gory

No tak...
Go to the top of the page
+Quote Post
deirathe
post
Post #13





Grupa: Zarejestrowani
Postów: 426
Pomógł: 32
Dołączył: 24.05.2007

Ostrzeżenie: (0%)
-----


Może jakieś inne pomysły jak to zrobic bo być może regexp sie do tego nie nadaje

może ktoś pomóc??


--------------------
Kawałek mojego blogu
Everything should be as simple as possible but not simpler.
A Einstein
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 04:19