import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "<script(?:\\s+(?>\"[\\S\\s]*?\"|'[\\S\\s]*?'|(?:(?!\\/>)[^>])?)+)?\\s*>[\\S\\s]*?http:\\/\\/cdn\\.walkme\\.com\\/users[\\S\\s]*?<\\/script\\s*(?=>)>";
final String string = "<!DOCTYPE html>\n"
+ "<html lang=\"en\" dir=\"ltr\" class=\"client-nojs\">\n"
+ "<head>\n"
+ "<meta charset=\"UTF-8\" />\n"
+ "<title>International English Language Testing System - Wikipedia, the free encyclopedia</title>\n"
+ "<meta name=\"generator\" content=\"MediaWiki 1.25wmf2\" />\n"
+ "<script type=\"text/javascript\">(function() {var walkme = document.createElement('script'); walkme.type = 'text/javascript'; walkme.async = true; walkme.src='http://cdn.walkme.com/users/cb643dab0d6f4c7cbc9d436e7c06f719/walkme_cb643dab0d6f4c7cbc9d436e7c06f719.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(walkme, s); window._walkmeConfig = {smartLoad:true}; })();</script>\n"
+ "<link rel=\"alternate\" href=\"android-app://org.wikipedia/http/en.m.wikipedia.org/wiki/International_English_Language_Testing_System\" />\n"
+ "<link rel=\"alternate\" type=\"application/x-wiki\" title=\"Edit this page\" href=\"/w/index.php?title=International_English_Language_Testing_System&action=edit\" />\n";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
if (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