Arveen
Arveen

Reputation: 868

How match a complex string?

I have to extract only this url out of a list 3-4 urls

Url = http//:downloadXXX.megastuff.com/XXXXXXXXXXX

other urls belong to different domain. for ex

http//:zep.vipk.com/XXXx

I need to do this in android with

if (url.contains("http://www."))
{ then do something   }

Sorry if the question is noobish, I just started with java.

Upvotes: 0

Views: 172

Answers (1)

aroth
aroth

Reputation: 54806

You can use matches() to compare against a regex that matches URL's from the target domain, like:

if (url.matches("http\\://.*download.*\\.megastuff\\.com/.*") {
    //then do something
}

Upvotes: 3

Related Questions