From a9a73b12ad57b1a1d5d772abb03cff4b36658086 Mon Sep 17 00:00:00 2001 From: br1 Date: Sat, 2 Feb 2002 16:36:20 +0000 Subject: [PATCH] changed url detection to work with links within brackets --- source/mir/misc/StringUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 { -- 2.11.0