In my application I need get the link and break it if it is bigger than 10 (example) characters. The problem is, if I send the whole text, for example: "this is my website www.stackoverflow.com" directly to this matcher
Pattern patt = Pattern.compile("(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'\".,<>???“”‘’]))");
Matcher matcher = patt.matcher(text);
matcher.replaceAll("<a href=\"http://$1\" target=\"_blank\">$1</a>");
It would show the whole website, without breaking it.
What I was trying to do, is to get the value of $1, so I could break the second one, keeping the first one correctly.
I've got another method to break the string up.
What I want to get is only the website so I could break it after all.