javascript Reg Exp to match specific domain name

前端 未结 6 2074
小鲜肉
小鲜肉 2021-01-12 09:34

I have been trying to make a Reg Exp to match the URL with specific domain name.

So if i want to check if this url is from example.com what reg exp should be the bes

6条回答
  •  礼貌的吻别
    2021-01-12 10:09

    Use this:

    /^[a-zA-Z0-9_.+-]+@(?:(?:[a-zA-Z0-9-]+\.)?[a-zA-Z]+\.)?
    (domain|domain2)\.com$/g
    

    To match the specific domain of your choice.

    If you want to match only one domain then remove |domain2 from (domain|domain2) portion.

    It will help you. https://www.regextester.com/94044

提交回复
热议问题