I wanna detect exact domain url
in string and then change that with another string and finally make it clickable in TextView
.
What I want:
this is sample text with one type of url mydomain.com/pin/123456. another type of url is mydomain.com/username.
Wel, I wrote this regex:
([Hh][tT][tT][pP][sS]?://)?(?:www\\.)?example\\.com/?.*
([Hh][tT][tT][pP][sS]?://)?(?:www\\.)?example\\.com/pin/?.*
this regex can detect:
http://www.example.com
https://www.example.com
www.example.com
example.com
Hhtp://www.example.com // and all other wrong type in http
with anything after .com
Issues:
1. How detect end of domain ( with space or dot)
2. How detect two type of domain, one with /pin/
and another without?
3. How to replace detected domain like mydomain.com/pin/123
with PostLink
and mydomain.com/username
with ProfileLink
4. I know how to make them clickable with Linkify
but if it possible show me best way to provide content provider for links to open each link with proper activity