import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "((?:http:\\/\\/+|www\\.+|https:\\/\\/+)(?:\\W+|\\S+|\\s+|.+)(?:\\.net+|\\.ro+))";
final String string = "glass shoes door window door glasses. window glasses sunglasses\n"
+ "glass\n"
+ "asdblog\n"
+ "{www.asdblog.iqads.net}\n"
+ "{http://creator.iqads.ro/NESCAFE3in1}\n"
+ "http://twitter.com/share\n"
+ "http://cdn.iqads.ro/photos/tags/11912.png\n"
+ "http://cluj.tecomm.ro/\n"
+ "http://www.godmother.ro\n"
+ "http://www.facebook.com/godmotherBTL\n"
+ "http://twitter.com/share\n"
+ "http://media.iqads.ro/2015/10/rm2hb-cover-400.jpg\n"
+ "http://media.iqads.ro/2015/09/vv-cover-800-cover-400.jpg\n"
+ "http://media.iqads.ro/2015/08/razvan-mitoiu-photo-cover-400.jpg\n"
+ "http://media.iqads.ro/2015/06/dsc7179-cover-400.jpg\n"
+ "http://media.iqads.ro/2015/05/raluca2-cover-400.jpg\n"
+ "http://media.iqads.ro/2015/05/1me-cover-400.jpg\n"
+ "http://cdn.iqads.ro/photos/tags/263355.png\n"
+ "http://cdn.iqads.ro/photos/tags/32786.png\n"
+ "http://cdn.iqads.ro/photos/tags/22703.png\n"
+ "http://cdn.iqads.ro/photos/tags/23589.png\n"
+ "http://cdn.iqads.ro/photos/tags/228683.png\n"
+ "http://cdn.iqads.ro/photos/tags/23696.png\n"
+ "http://cdn.iqads.ro/photos/tags/16968.png\n"
+ "http://cdn.iqads.ro/photos/tags/263192.png\n"
+ "http://www.blueidea.ro\n"
+ "http://www.blueidea.ro";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
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