标签: python regex
是否有正则表达式可以从网页上的嵌入式YouTube视频中获取youtube视频链接或ID?
答案 0 :(得分:1)
找到: "<object(.*)youtube.com/v/(.*)\"(.*)</object>"
"<object(.*)youtube.com/v/(.*)\"(.*)</object>"
转换为链接: replace("<object(.*)youtube.com/v/(.*)\"(.*)</object>", '<a href="http://www.youtube.com/watch?v=\\2">click here</a>', $str)
replace("<object(.*)youtube.com/v/(.*)\"(.*)</object>", '<a href="http://www.youtube.com/watch?v=\\2">click here</a>', $str)
source