|
|
|
| Здравствуйте, скажите пожалуйста, как ссылку получить вот из этого текста:
<div id="download_url" >
<form action="http://site.com/build.jpg" method="get" onSubmit="download_started();show_begin_popup(0);">
<input class="download" value="Скачать файл" type="submit"/>
</form>
</div>
|
Нужно получить http://site.com/build.jpg
Спасибо за внимание! | |
|
|
|
|
|
|
|
для: Icen
(13.09.2008 в 14:13)
| |
<?
$text = '<div id="download_url" >
<form action="http://site.com/build.jpg" method="get" onSubmit="download_started();show_begin_popup(0);">
<input class="download" value="Скачать файл" type="submit"/>
</form>
</div>';
preg_match('#http://[^\s"\'>]*#', $text, $t);
print $t[0] . '<hr/>';
preg_match('#<form action=(["\'])((?:(?!\1).)*)\1#', $text, $t);
print $t[2] . '<hr/>';
preg_match('#(?<=<form action=["\'])[^"\']*#', $text, $t);
print $t[0] . '<hr/>';
preg_match('#<form action=["\']?(.*?)[\s"\'>]#s', $text, $t);
print $t[1] . '<hr/>';
preg_match(
'#<div[^>]+?id="download_url"(?:(?!</div|<form).[^<]*)*<form[^>]*?\saction=["\']?([^\s"\'>]*)#si'
, $text, $t);
print $t[1] . '<hr/>';
preg_match('#["\'](http://[^/]+/build.jpg)["\']#', $text, $t);
print $t[1] . '<hr/>';
?>
|
| |
|
|
|