[英]How to get multiple urls http and https using regular expressions?
http:\/\/embed.(.*).com\/\?id=([0-9]+)
$userAgent = array('http' => array('user_agent' => 'Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D)'));
is there anyway to get both http and https with the above code? 无论如何,使用上面的代码得到http和https?
Add an optional pattern s?
添加可选模式s?
( s
will match an s
and ?
will make the regex engine match it one or zero times): ( s
将匹配s
和?
将使正则表达式引擎匹配一次或零次):
https?:\/\/embed\.(.*)\.com\/\?id=([0-9]+)
^^
I also think you forgot to escape the dots after embed
and before com
. 我也认为你在embed
之后和com
之前忘了逃避点。 You also might want to replace (.*)
with ([^\\/]*)
to avoid overflowing across /
separated URL sections, so consider using 您还可能希望将(.*)
替换为([^\\/]*)
以避免溢出/
分隔的URL部分,因此请考虑使用
https?:\/\/embed\.([^\/]*)\.com\/\?id=([0-9]+)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.