I. If you have always the struture : word url word (and url without spaces) you can use :
String str = "others. https://forum.com/thread.jspa[...]art=75&t-start=0 I recently";
Matcher m = Pattern.compile("(.*)http.*\\s(.*)").matcher(str); // (capture1)url (capture2)
String target = "";
if (m.find()) {
target = m.group(1) + m.group(2);
}
System.out.println(target); //others. recently
The pattern will capture 2 groups, the one before the url, and the one after the space after the url
II. Iterate over the words of the sentence and keep the ones which does not contains "http" which significate that it's an url
StringBuilder builder = new StringBuilder();
for (String word : str.split(" ")) {
if (!word.contains("http")) {
builder.append(word).append(" ");
}
}
String target = builder.deleteCharAt(builder.length()-1).toString();
System.out.println(target); //others. recently
III. Same as II. but wih streams (ONE LINE solution) :
String target = Arrays.asList(str.split(" "))
.stream()
.filter(word -> !word.contains("http"))
.map(word -> word + " ")
.collect(Collectors.joining());