Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract complete url from a text in android

Tags:

string

regex

url

I want to extract complete url from a large text such that the complete url incuding the parameters are needed to be extraxted.

It should support all url format...

Eg of urls

  1. www.facebook.com/mainhoon/jikii/50
  2. http://www.alphabet.com?user=50&tyn=40
  3. m.gmail.com etc

Eg of text:

hi hello howe are you look at my code http://www.stackoverflow.com?adiadajda here we got the answer also check this url www.myspace.in that gives bla bla bla

like image 853
Shankar Avatar asked Feb 21 '26 10:02

Shankar


1 Answers

Extract single url via Kotlin

private fun extractUrl(input: String) =
        input
            .split(" ")
            .firstOrNull { Patterns.WEB_URL.matcher(it).find() }
like image 156
Иван Захариев Avatar answered Feb 23 '26 02:02

Иван Захариев