3

I'm using 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 end up with this text without '#' character.

I want to use it to search Instagram:

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

but Linkify opens a url with '#' character:

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

How can I remove '#' character from the link created with Linkify.

Kendra
  • 769
  • 1
  • 20
  • 34

1 Answers1

-1

try this

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); } };

hugerde
  • 919
  • 1
  • 12
  • 27