import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(\\/(static)\\/)(.*)([0-9]{13}\\/)";
final String string = " <link>http://static1.squarespace.com/static/56eadbb9e707eb1e1ec78cca/5743a5702b8dde05e892a971/59fa119a24a694d3151e9f79/1509632943781/medellin-flower-festival-colombia-conde-nast-traveller-1april14-rex_-1.jpg</link>\n"
+ " <title>attachment-59fa119a24a694d3151e9f79</title>\n"
+ " \n"
+ " <img src=\"http://static1.squarespace.com/static/56eadbb9e707eb1e1ec78cca/5743a5702b8dde05e892a971/5a007536e4966b51e8d63db6/1509979480047/buenos-aires-unsettled-argentina-retreat-digital-nomad.jpgbuenos-aires-unsettled-argentina-retreat-digital-nomad?format=original\" alt=\"\"/>\n\n\n"
+ " <img src=\"http://static1.squarespace.com/static/56eadbb9e707eb1e1ec78cca/5743a5702b8dde05e892a971/5a007536e4966b51e8d63db6/1509979480047/buenos-aires-unsettled-argentina-retreat-digital-nomad.jpgbuenos-aires-unsettled-argentina-retreat-digital-nomad?format=original\" alt=\"\"/>\n\n"
+ "\"http://static1.squarespace.com/static/56eadbb9e707eb1e1ec78cca/5743a5702b8dde05e892a971/59fa1b0b71c10b694346e433/1509563194043/22860715_372374486541985_6060851298842968064_n.jpg\",";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html