How to combine multiple regular expressions into one line?

前端 未结 2 1810
一个人的身影
一个人的身影 2021-01-22 08:20

My script works fine doing this:

images = re.findall(\"src.\\\"(\\S*?media.tumblr\\S*?tumblr_\\S*?jpg)\", doc)
videos = re.findall(\"\\S*?(http\\S*?video_file\\S         


        
2条回答
  •  长情又很酷
    2021-01-22 08:51

    As mentioned in the comments, a pipe (|) should do the trick.

    The regular expression

    (src.\"(\S*?media.tumblr\S*?tumblr_\S*?jpg))|(\S*?(http\S*?video_file\S*?tumblr_[a-zA-Z0-9]*))
    

    catches either of the two patterns.

    Demo on Regex Tester

提交回复
热议问题