changed url detection to work with links within brackets
authorbr1 <br1>
Sat, 2 Feb 2002 16:36:20 +0000 (16:36 +0000)
committerbr1 <br1>
Sat, 2 Feb 2002 16:36:20 +0000 (16:36 +0000)
source/mir/misc/StringUtil.java

index e226c06..44c4538 100755 (executable)
@@ -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,"<a href=\"$0\">$0</a>");
     } 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,"<img src=\""+imageRoot+"/"+extImage+"\" border=\"0\"/>&#160;<a href=\"$0\">$0</a>");
       } else {