-1
我有一個文本文件,其中輸入了許多不同的URL。從文本文件中提取URL
例如:
file:///g:/somepath/subpath/file.txt
/somepath/subpath/file.txt
Http://www.domain.at/path/file.txt
我需要他們從文件中提取。在文本文件中沒有HTML,所以我不能搜索像href。
是否有我可以使用的PHP的RegEx?
我有一個文本文件,其中輸入了許多不同的URL。從文本文件中提取URL
例如:
file:///g:/somepath/subpath/file.txt
/somepath/subpath/file.txt
Http://www.domain.at/path/file.txt
我需要他們從文件中提取。在文本文件中沒有HTML,所以我不能搜索像href。
是否有我可以使用的PHP的RegEx?
如果您需要更多幫助,請發佈整個文件。從給定的...
<?php
$string = 'file:///g:/somepath/subpath/file.txt
dasdsaddasdf
dsafddsad /somepath/subpath/file.txt
Http://www.domain.at/path/file.txt adsadsadasd
';
preg_match_all('#([\S]+)\.txt#is', $string, $matches);
print_r($matches[1]);
?>
結果
Array
(
[0] => file:///g:/somepath/subpath/file
[1] => /somepath/subpath/file
[2] => Http://www.domain.at/path/file
)
您是否嘗試過的東西? – 2011-12-15 20:32:16