Android binds without the first character

I use Linkify to detect tags (#) in a TextView.

Pattern userMatcher = Pattern.compile("\\B@[^:\\s]+");
String userViewURL = "https://www.instagram.com/explore/tags/";
Linkify.addLinks(tvComment, userMatcher, userViewURL);

The URL is supposed to contain text without the '#' character.

I want to use it to search Instagram:

https://www.instagram.com/explore/tags/mytag

but Linkify opens the url with the character '#':

https://www.instagram.com/explore/tags/#mytag

How to remove the "#" character from a link created using Linkify.

+4
source share
1 answer

try it

Linkify.TransformFilter transformFilter = new Linkify.TransformFilter() { //skip the first character to filter out '@' public String transformUrl(final Matcher match, String url) { return url.substring(1); } };

0
source

Source: https://habr.com/ru/post/1620141/


All Articles