匹配包含空格的图像链接 [英] Matching images links containing spaces
本文介绍了匹配包含空格的图像链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$update = ' sometext http://www.site1.com/images/some image with spaces.jpg some other text http://www.site2.com/some_image.jpg';
preg_match_all('#(?:<\>]+href=\")?(?:http://)?(http(s?)://([^\s]*)\.(jpg|gif|png))#', $update, $group_imagelink);
echo $group_imagelink[1][0];
echo $group_imagelink[1][1];
我的正则表达式不想从带有空格的文本中提取链接.我需要用 20%
替换链接中的空格,以便在 copy()
之后使用,但我仍然希望用空格保留我的文本.我该怎么做?
My regular expression doesn't want to extract a link from text with spaces.
I need to replace spaces in the link with 20%
for use after copy()
, but I still want keep my text with spaces. How can I do this?
此外,我的代码是否免受http://www.myserver.com/virus.exe#fakeParam=.jpg?
Also, is my code safe from things like http://www.myserver.com/virus.exe#fakeParam=.jpg?
推荐答案
这对我有用:
我换了
[^\s]*
与
.*?
这篇关于匹配包含空格的图像链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文