【发布时间】:2015-05-23 13:28:29
【问题描述】:
我是 php 的初学者,我不知道如何解决这个问题。
我有一个包含段落和链接的文本文件,这是来自文本文件的示例:
$string = ("Lorem 'Ipsum' is simply: dummy 'http://www.exmplelink1.com/blah/blah/file 1 b.txt' text of the printing 'http://www.exmplelink1.com/blah/blah/file 1 c.txt' and typesetting industry. Lorem Ipsum 'http://www.exmplelink2.com/blah/file.txt' has been, the 'industry's standard'");
请注意字符串中有很多单引号和两个域名:exmplelink1 和 exmplelink2
-
我如何只获取 exmplelink1 链接(单引号之间的完整链接)在这种情况下有两个链接:
'http://www.exmplelink1.com/blah/blah/file 1 b.txt' 'http://www.exmplelink1.com/blah/blah/file 1 c.txt'
谢谢你的帮助:)
【问题讨论】:
-
使用正则表达式。像
'http.*?'这样的东西应该可以工作。 -
我可能会补充,我真的不知道正则表达式:(
-
我应该替换 '?'与域名?因为我有太多不同域名的链接,我只想获取特定域的链接
标签: php