Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 使用正则表达式解析URL_Regex_Vb.net_Url_Thumbnails - Fatal编程技术网

Regex 使用正则表达式解析URL

Regex 使用正则表达式解析URL,regex,vb.net,url,thumbnails,Regex,Vb.net,Url,Thumbnails,我有Youtube和Dailymotion视频URL,如下所示: 为Youtube 每日运动 我想获得这些视频的预览图像,因此我必须按如下方式解析这些链接: 为Youtube 每日运动 请帮帮我。我是regex的新手…YouTube: ResultString = Regex.Replace(SubjectString, "http.*?v[=/]([^\s&#]+)\S+", "http://img.youtube.com/vi/$1/default

我有Youtube和Dailymotion视频URL,如下所示:

为Youtube

每日运动

我想获得这些视频的预览图像,因此我必须按如下方式解析这些链接:

为Youtube

每日运动


请帮帮我。我是regex的新手…

YouTube:

ResultString = Regex.Replace(SubjectString, "http.*?v[=/]([^\s&#]+)\S+", "http://img.youtube.com/vi/$1/default.jpg", RegexOptions.IgnoreCase)
每日运动:

ResultString = Regex.Replace(SubjectString, "http.*?v[=/]([^\s&#]+)\S+", "http://img.youtube.com/vi/$1/default.jpg", RegexOptions.IgnoreCase)
一个简单的字符串替换就可以了,但下面是正则表达式:

ResultString = Regex.Replace(SubjectString, "http://www\.dailymotion\.com/video/", "http://www.dailymotion.com/thumbnail/video/", RegexOptions.IgnoreCase)

你必须使用正则表达式吗?难道你不能解析字符串并在第三个“/”处拆分它吗?你知道,对于youtube,你想用“vi”替换第三个“/”后面的六个字符,对于日常运动视频,你想用第三个“/”后面的“缩略图”替换“video”,这确实包含了youtube所需的所有信息,我就是这样理解的
http://www.youtube.com/watch?v=http://img.youtube.com/vi/4ioaMXTsAv8/default.jpg
但我想要
http://img.youtube.com/vi/4ioaMXTsAv8/default.jpg
天哪,太尴尬了!不知道发生了什么,我想我已经测试过了,但我一定是在梦游。。。。请尝试更新的代码。:)谢谢Vignesh,很高兴它有帮助。:)嗨,我发布了关于Javascript的新问题