Warm tip: This article is reproduced from serverfault.com, please click

write Perl Regex

发布于 2020-11-30 06:09:26

I have some URLs like below :

http://srv1.Example.com/movie/99/09/06/The.True.Adventures.of.Wolfboy.2019.720p.asli.mkv.T8d89281498deef0.mkv?md5=d0c61a41d7d0095edc0210244561bb34&expires=1609025725

and

http://srv2.Example.com/movie/99/09/06/The.True.Adventures.of.Wolfboy.2019.720p.asli.mkv

Now I want select these Example.com URLs and index them. so need some regex for do it and export the path from it . I make regex, something like this :

http://[^/]+.Example.com/(?P[^?].(?:mp4|mkv))(.)

Problem: When use above Regex, the path that export for me is like :

path=movie/99/09/06/The.True.Adventures.of.Wolfboy.2019.720p.asli.mkv.T8d89281498deef0.mkv

but I want the regex that support both URLs and export the path like :

path=movie/99/09/06/The.True.Adventures.of.Wolfboy.2019.720p.asli.mkv

I appreciate it, if help me to write a regex to export the path from the URL like :

path=movie/99/09/06/The.True.Adventures.of.Wolfboy.2019.720p.asli.mkv

Best Regards,

Hamed Haghshenas

Questioner
Hamed Haghshenas
Viewed
0
Hao Wu 2020-11-30 14:43:44

Is this what you want?

http:\/\/(?:[^\/]+\.)?Example\.com\/(?P<path>[^?]+?\.(?:mkv|mp4))

See the tests here