Regex to detect one of several strings

前端 未结 7 1703
野趣味
野趣味 2020-12-08 13:20

I\'ve got a list of email addresses belonging to several domains. I\'d like a regex that will match addresses belonging to three specific domains (for this example: foo, bar

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 13:33

    should be more generic, the a shouldn't count, although the @ should.

    /@(foo|bar|baz)(?:\W|$)/
    

    Here is a good reference on regex.

    edit: change ending to allow end of pattern or word break. now assuming foo/bar/baz are full domain names.

提交回复
热议问题