How Can I Linkify Urls Which Appear In Plain Text?
How can I linkify URLs which appear in plain text? For example, Today i want to share a link: www.google.com I would like to make 'www.google.com' clickable by putting
Solution 1:
You could use the regexp from Matthew O'Riordan's page to match an URL with or even without the protocol part:
/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/
Solution 2:
You can use Linkify which is simple to use, it will surround the link in given selector in plain text to links.
Post a Comment for "How Can I Linkify Urls Which Appear In Plain Text?"