How to use the pipe operator as part of a regular expression?

后端 未结 1 2027
陌清茗
陌清茗 2020-12-10 17:54

I want to match the url within strings like

u1 = \"Check this out http://www.cnn.com/stuff lol\"
u2 = \"see http://www.cnn.com/stuff2\"
u3 = \"http://www.esp         


        
1条回答
  •  [愿得一人]
    2020-12-10 18:34

    Non-grouping matches.

    re.findall("[^ ]*.(?:cnn|espn).[^ ]*", u1)
    

    0 讨论(0)
提交回复
热议问题