java - regex matching negation to ebay sites -


i have regex match ebay sites:

(?i)^((http|https)://)?(\w+\.)*ebay.(\w+.)+ 

i want negate it, match all, except sites

i tried:

(?! pattern ) (?!pattern) [^pattern] 

but nothing worked. maybe first regex unoptimal?

testcase in java:

pattern querypattern = pattern.compile("(?i)^((http|https)://)?(\\w+\\.)*ebay.(\\w+.)+"); list<string> queries = new linkedlist(); queries.add("http://www.ebay.com/blabla"); queries.add("www.ebay.com/blabla"); queries.add("www.ebay.com/blabla"); queries.add("www.ebay.com.hk/blabla"); queries.add("www.ebay.co.uk"); queries.add("ttt.ebay.com"); queries.add("ru.ebay.com"); queries.add("test.ru.ebay.com"); queries.add("test.ru.ebay.com"); queries.add("ebay.com"); queries.add("naebay.com"); queries.add("ru.naebay.ru"); queries.add("blah.ru"); (string query : queries) {   system.out.println(query + " " + querypattern.matcher(query).find()); } 

obvious response:

    pattern querypattern = pattern.compile("(?i)^((http|https)://)?(\\w+\\.)*ebay.(\\w+.)+");     list<string> queries = new linkedlist<string>();     ...      (string query : queries) {         if (querypattern.matcher(query).find() == false) {             system.out.println("non ebay site: " + query + " " + querypattern.matcher(query).find());         }     } 

output:

non ebay site: naebay.com false non ebay site: ru.naebay.ru false non ebay site: blah.ru false 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -