2
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 ???

Parth
  • 331
  • 2
  • 4
  • 8

1 Answers1

1

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?

Blundell
  • 75,855
  • 30
  • 208
  • 233
  • if you'd like to use the ampersand, you could also just escape it with s backslash, so it gets recognised as character instead of a regex keyword... – Makibo Jul 02 '13 at 08:03