Shan Arshad
Shan Arshad

Reputation: 151

Regular Expression: if, else if to use in Java

I am trying to write a regular expression in which I want to compare the URL's.

Any URL Matches http://*.xyz.com Except or Excluding http://m.xyz.com and http://m.product.xyz.com

So far I was trying to do it by using if else in RegExp but I couldn't be able to do it right...

(^http:\/\/)(((1)<!(m|m\.product))\.xyz\.co\.jp)?

Upvotes: 0

Views: 52

Answers (2)

CinCout
CinCout

Reputation: 9619

https?:\/\/(?!m\.|m\.product\.).*\.xyz\..*

This regex accepts all *.xyz.* domains except m.xyz.* and m.product.xyz.*. Also takes care of http or https.

Demo

Upvotes: 2

Mustofa Rizwan
Mustofa Rizwan

Reputation: 10466

You can try that:

^http:\/\/(?!m\.xyz\.com|m\.product\.xyz\.com).*\.xyz\.com$

Regex101 Demo

Upvotes: 3

Related Questions