Parth
Parth

Reputation: 331

Linkify using pattern

Pattern pattern = Pattern.compile("[a-zA-Z]+&");
    myCustomLink.setText("press Linkify& or on Android& to search it on google");
    Linkify.addLinks(myCustomLink,pattern, "http://www.google.ie/search?q=");

This code works perfectly but I cannot get it how patterns works and convert only Linkfy and Android as a link ???

Upvotes: 2

Views: 1040

Answers (1)

Blundell
Blundell

Reputation: 76534

It's a regular expression.

http://www.marksanborn.net/howto/learning-regular-expressions-for-beginners-the-basics/

http://www.regular-expressions.info/reference.html

it's saying get ' Letters followed by the &(ampersand) sign ' if you changed it to a . (fullstop) the . character has a special meaning in regex so you can't use it in this situation.

You could change it to: [a-zA-Z]+L

then anything like:

 press LinkifyL or on AndroidL to search it on google

will change to a link, get it?

Upvotes: 1

Related Questions