Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Wyrażenie regularne - wyciąganie URL
Falcon2
post
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 6.02.2009

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


Witam

Mógłby mi ktoś pomóc w napisaniu wyrażenia regularnego preg_match, które zwracałoby z takiego tekstu:
"jakas tresc jakas tresc http://www.strona.pl/cos.jpg jakas tresc jakas tresc"
tylko "http://www.strona.pl/cos.jpg" ?
Znaczy wyciągało adres URL obrazka z tekstu
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




  1. <?php
  2. $text='dfgs dfg sdfg sdg adgr <a href=\"http://test.pl/dfgsdfgsdfgadfasdfsd_ad\" target=\"_blank\">http://test.pl/dfgsdfgsdfgadfasdfsd_ad</a> /asdf asdfa sd';
  3.  
  4. preg_match('/http://.*?[s]/is', $text, $matches);
  5. print_r($matches);
  6. ?>
Go to the top of the page
+Quote Post

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: 22.08.2025 - 16:59