I am trying to parse links from plain text and I came across this really useful site:
http://blog.mattheworiordan.com/post/13174566389/url-regular-expression-for-links-with-or-without
There is an example of usage of that regex to match urls however I have some trouble getting around it syntactically.
What is the equivalent of this in Java:
$(function() {
var urlRegEx = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-]*)?\??(?:[\-\+=&;%@\.\w]*)#?(?:[\.\!\/\\\w]*))?)/g;
$('#target').html($('#source').html().replace(urlRegEx, "<a href='$1'>$1</a>"));
});
Any help or a solution would be most appreaciated.
I am aware of the Pattern
and Matcher
classes in Java but I do not know what jquery's .html()
does in order to implement a solution. Thanks in advance.