From: br1 Date: Sat, 2 Feb 2002 16:36:20 +0000 (+0000) Subject: changed url detection to work with links within brackets X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=a9a73b12ad57b1a1d5d772abb03cff4b36658086;p=mir.git changed url detection to work with links within brackets --- diff --git a/source/mir/misc/StringUtil.java b/source/mir/misc/StringUtil.java index e226c06a..44c4538c 100755 --- a/source/mir/misc/StringUtil.java +++ b/source/mir/misc/StringUtil.java @@ -867,8 +867,10 @@ public final class StringUtil { */ public static String createURLLinks(String haystack) { try { + //dieser Ausdruck brauch dringend fachliche Beratung - RE regex = new RE("((https://)|(http://)|(ftp://))+([a-zA-Z0-9_-]+).([a-zA-Z0-9_.:-]+)/([^ \t\r\n<>]+[^ \t\r\n.,<>])"); + //RE regex = new RE("((https://)|(http://)|(ftp://))+([a-zA-Z0-9_-]+).([a-zA-Z0-9_:-]+)/([^ \t\r\n<>)]+[^ \t\r\n,<>])"); + RE regex = new RE("((https://)|(http://)|(ftp://)){1}([a-zA-Z0-9_-]+).([a-zA-Z0-9_.:-]+)/?([^ \t\r\n<>\\)\\]]+[^ \t\r\n.,<>\\)\\]])"); return regex.substituteAll(haystack,"$0"); } catch(REException ex){ return null; @@ -887,7 +889,8 @@ public final class StringUtil { public static String createURLLinks(String haystack, String title, String imageRoot,String extImage) { try { //dieser Ausdruck brauch dringend fachliche Beratung - RE regex = new RE("((https://)|(http://)|(ftp://))+([a-zA-Z0-9_-]+).([a-zA-Z0-9_.:-]+)/?([^ \t\r\n<>]+[^ \t\r\n.,<>])"); + RE regex = new RE("((https://)|(http://)|(ftp://)){1}([a-zA-Z0-9_-]+).([a-zA-Z0-9_.:-]+)/?([^ \t\r\n<>\\)\\]]+[^ \t\r\n.,<>\\)\\]])"); + if (title == null) { return regex.substituteAll(haystack," $0"); } else {