Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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
正则表达式匹配用于精确匹配,而不是python中的所有匹配_Python_Regex_String - Fatal编程技术网

正则表达式匹配用于精确匹配,而不是python中的所有匹配

正则表达式匹配用于精确匹配,而不是python中的所有匹配,python,regex,string,Python,Regex,String,嗨,我有一个字符串作为http://www.yifysubtitles.com/subtitles/blockers2018720pwebripx264-ytsam-arabic-128849“>subtitle Blockers.2018.720p.WEBRip.x264-[YTS.AM]0Chinese6English0Serbian2Spanish您的字符串实际上是html-您应该使用html解析器。我建议使用优秀的lxml.html解析器 为了回答您的问题,正则表达式在默认情况下是贪婪的

嗨,我有一个字符串作为
http://www.yifysubtitles.com/subtitles/blockers2018720pwebripx264-ytsam-arabic-128849“>subtitle Blockers.2018.720p.WEBRip.x264-[YTS.AM]0Chinese6English0Serbian2Spanish

您的字符串实际上是html-您应该使用html解析器。我建议使用优秀的lxml.html解析器


为了回答您的问题,正则表达式在默认情况下是贪婪的,这意味着您的
+
部分将获取尽可能多的字符以满足条件。因此,您将获得第一个
/subtitles/
和最后一个
-english \-yify-
以及介于两者之间的所有字符。

使用
+?
作为非贪婪限定符。我尝试不使用请检查我的正则表达式,使用类似于
\w
的东西代替
,以避免匹配空格和
等。此字符串也类似于该字符串,但不匹配相同的正则表达式,具有不同的电影name@H肯利德,你能看见吗