How to parse a url from a String in android?

Viewed 30088

I want to parse the url from a String in android. The example String is

"This is a new message. The content of the message is in 'http://www.example.com/asd/abc' "

I want to parse the url http://www.example.com/asd/abc from the String without using the subString method.

7 Answers

I use this in Kotlin

fun findAllUrls(text: String): List<String> {
    return Regex(Patterns.WEB_URL.pattern()).findAll(text).map {
        it.value
    }.toList()
}
Related