This website contains different Url, But i want my application should vist urls only which contains specific keyword like “drugs” like
if urls are
http://website.com/countryname/drug/info/A
http://website.com/countryname/Browse/Alphabet/D?cat=company
it should visit first URL.so how to match a specific keyword drug in url.I know it can be done using regexp also,but have but i am new to it
I am using Java here
You can check if string contains a word with method contains().
if(myString.contains("drugs"))If you need only URLs containing /drug/ try to do something like this:
(/|$)means that after/drugcan be only a slash ( / ) or nothing at all (dollar means end of the line).So this regex will find all if your string is like.../drug/...or.../drug