Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Wyrażenie regularne, problem ..
ciniutek
post
Post #1





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 29.05.2011

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


Witam . Mam pewien problem z wyrażeniem regularnym . Dokładnie to z wyciągnięciem pewnej treści .. Mam do wyciągnięcia dwie linijki kodu :

  1. <div style="cursor: pointer;" id="menuc286">tytuł</div>
  2. <div style='display: none;' class='hideit menuh286'>


Próbowałem stosować już \n ale nic nie daje ..
A oto kawałek mojego skryptu :

  1. $regexp = "<div style=\"cursor: pointer;\" id=\"(.*)\">(.*)<\/div>";
  2. if(preg_match_all("/$regexp/", $nowe, $matches, PREG_SET_ORDER)) {
  3. foreach($matches as $match)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tolomei
post
Post #2





Grupa: Zarejestrowani
Postów: 450
Pomógł: 135
Dołączył: 18.11.2010
Skąd: Wschowa

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


To co podałeś działa dla mnie bez zarzutu.
Może z pętlą foreach coś nie tak było?
Odpal sobie to:

  1. $text = '<div style="cursor: pointer;" id="menuc286">tytuł</div>
  2. <div style=\'display: none;\' class=\'hideit menuh286\'>
  3. <div style="cursor: pointer;" id="abcd">12345</div>
  4. <div style=\'display: none;\' class=\'hideit menuh286\'>';
  5.  
  6. $regexp = "<div style=\"cursor: pointer;\" id=\"(.*)\">(.*)<\/div>";
  7. if(preg_match_all("/$regexp/", $text, $matches, PREG_SET_ORDER)) {
  8. var_dump($matches);
  9. }


A co takiego chciałeś z drugiej linijki wyciągnąć ?
Czy chciałeś ją po prostu odnaleźć ?
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 9.10.2025 - 12:58