import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^(((((.+\\.)*(msedge))|((((.+\\.)*(scsquery\\-ss\\-us))|((.+\\.)*(scsquery\\-ss\\-eu))|((.+\\.)*(scsquery\\-ss\\-asia))|((.+\\.)*(scsinstrument\\-ss\\-us))|((.+\\.)*(skypemaprdsitus)))\\.(trafficmanager))|((.+\\.)*(msftauth))|((((((((.+\\.)*(policykeyservice)))\\.(dc)))\\.(ad)))\\.(msft))|((.+\\.)*(phonefactor))|((((((((.+\\.)*(informationprotection)))\\.(hosting)))\\.(portal))|((.+\\.)*(amp)))\\.(azure))|((((((.+\\.)*(ecn)))\\.(dev)))\\.(virtualearth))|((((.+\\.)*(apis)))\\.(live))|((((.+\\.)*(spoprod\\-a)))\\.(akamaihd))|((((.+\\.)*(cdn)))\\.(onenote))|((.+\\.)*(msecnd))|((.+\\.)*(msftauthimages))|((((((((.+\\.)*(officecdn)))\\.(microsoft)))\\.(com)))\\.(edgesuite))|((.+\\.)*(msauth))|((((.+\\.)*(mlccdnprod)))\\.(azureedge))|((.+\\.)*(msauthimages))|((((((.+\\.)*(insertmedia)))\\.(bing))|((((.+\\.)*(videocontent))|((.+\\.)*(videoplayercdn))|((.+\\.)*(contentstorage))|((.+\\.)*(video)))\\.(osi))|((((.+\\.)*(support)))\\.(content))|((.+\\.)*(cdn))|((.+\\.)*(attachments))|((.+\\.)*(suite)))\\.(office))|((.+\\.)*(windows)))\\.(net))|((((((.+\\.)*(appsforoffice))|((.+\\.)*(c1))|((.+\\.)*(crl))|((((.+\\.)*(r)))\\.(office))|((.+\\.)*(aria))|((.+\\.)*(technet))|((.+\\.)*(officecdn))|((.+\\.)*(officeredir))|((.+\\.)*(officepreviewredir))|((.+\\.)*(office15client))|((.+\\.)*(go))|((.+\\.)*(msdn))|((((.+\\.)*(activation)))\\.(sls))|((.+\\.)*(support))|((.+\\.)*(compass\\-ssl))|((.+\\.)*(docs))|((((.+\\.)*(events)))\\.(data))|((.+\\.)*(officeclient)))\\.(microsoft))|((.+\\.)*(outlook))|((.+\\.)*(microsoftonline))|((((.+\\.)*(secure)))\\.(skypeassets))|((.+\\.)*(sharepointonline))|((((.+\\.)*(informationprotection))|((.+\\.)*(management))|((.+\\.)*(adhybridhealth)))\\.(azure))|((((.+\\.)*(g))|((.+\\.)*(officeapps))|((((.+\\.)*(client)))\\.(hip)))\\.(live))|((.+\\.)*(onenote))|((((.+\\.)*(\\-myfiles))|((.+\\.)*(\\-files)))\\.(sharepoint))|((((.+\\.)*(admin))|((.+\\.)*(www)))\\.(onedrive))|((.+\\.)*(o365weve))|((((.+\\.)*(platform)))\\.(linkedin))|((.+\\.)*(azurerms))|((((.+\\.)*(prod))|((.+\\.)*(shellprod)))\\.(msocdn))|((.+\\.)*(microsoftonline\\-p))|((((.+\\.)*(cdn)))\\.(optimizely))|((((.+\\.)*(quicktips)))\\.(skypeforbusiness))|((((.+\\.)*(ajax)))\\.(aspnetcdn))|((.+\\.)*(aadrm))|((((.+\\.)*(products))|((.+\\.)*(delve\\-gcc))|((.+\\.)*(support))|((.+\\.)*(templates))|((.+\\.)*(outlook))|((.+\\.)*(delve))|((((.+\\.)*(webshell)))\\.(suite)))\\.(office))|((.+\\.)*(office365))|((.+\\.)*(sfbassets))|((((((.+\\.)*(skydrive)))\\.(wns)))\\.(windows))|((.+\\.)*(skype)))\\.(com))|((((.+\\.)*(svc))|((((.+\\.)*(auth)))\\.(gfx))|((.+\\.)*(aka))|((.+\\.)*(mstea))|((((.+\\.)*(assets)))\\.(onestore))|((((.+\\.)*(oneclient)))\\.(sfx)))\\.(ms)))$ ";
final String string = "aadrm.com\n"
+ "account.activedirectory.windowsazure.com\n"
+ "acompli.net\n"
+ "ad.atdmt.com\n"
+ "adhybridhealth.azure.com\n"
+ "adl.windows.com\n"
+ "ajax.aspnetcdn.com\n"
+ "aka.ms\n"
+ "appex-rf.msn.com\n"
+ "assets.onestore.ms\n"
+ "assets-yammer.com\n"
+ "atp.azure.com\n"
+ "auth.gfx.ms\n"
+ "autologon.microsoftazuread-sso.com\n"
+ "azure.net\n"
+ "azureedge.net\n"
+ "azurerms.com\n"
+ "bing.com\n"
+ "bit.ly\n"
+ "by.uservoice.com\n"
+ "c.bing.net\n"
+ "cdn.optimizely.com\n"
+ "clientconfig.microsoftonline-p.net\n"
+ "cloudapp.net\n"
+ "ctldl.windowsupdate.com\n"
+ "dc.services.visualstudio.com\n"
+ "ecn.dev.virtualearth.net\n"
+ "eus-www.sway-cdn.com\n"
+ "eus-www.sway-extensions.com\n"
+ "excelbingmap.firstpartyapps.oaspapps.com\n"
+ "firstpartyapps.oaspapps.com\n"
+ "graph.facebook.com\n"
+ "hockeyapp.net\n"
+ "informationprotection.azure.com\n"
+ "isrg.trustid.ocsp.identrust.com\n"
+ "live.com\n\n"
+ "live.net\n"
+ "login.windows-ppe.net\n"
+ "lync.com\n"
+ "management.azure.com\n"
+ "mem.gfx.ms\n"
+ "microsoft.com\n\n\n\n\n\n\n\n\n"
+ "microsoftonline.com\n\n\n\n\n\n\n\n\n\n\n\n"
+ "microsoftonline-p.com\n\n"
+ "microsoftstream.com\n"
+ "msappproxy.net\n"
+ "msauth.net\n"
+ "msauthimages.net\n"
+ "msecnd.net\n"
+ "msedge.net\n"
+ "msftauth.net\n"
+ "msftauthimages.net\n"
+ "msftidentity.com\n"
+ "msidentity.com\n"
+ "msocdn.com\n"
+ "mstea.ms\n"
+ "o365weve.com\n"
+ "office.com\n\n\n\n\n\n\n\n\n\n\n"
+ "office.net\n"
+ "office365.com\n\n"
+ "officecdn.microsoft.com.edgesuite.net\n"
+ "oneclient.sfx.ms\n"
+ "onedrive.com\n"
+ "onenote.com\n"
+ "onmicrosoft.com\n"
+ "outlook.com\n\n"
+ "outlook.uservoice.com\n"
+ "outlookmobile.com\n"
+ "partnerservices.getmicrosoftkey.com\n"
+ "peoplegraph.firstpartyapps.oaspapps.com\n"
+ "phonefactor.net\n"
+ "policykeyservice.dc.ad.msft.net\n"
+ "portal.cloudappsecurity.com\n"
+ "prod.firstpartyapps.oaspapps.com.akadns.net\n"
+ "secure.skypeassets.com\n"
+ "sfbassets.com\n"
+ "sharepoint.com\n"
+ "sharepointonline.com\n"
+ "skydrive.wns.windows.com\n"
+ "skype.com\n\n"
+ "skypeforbusiness.com\n"
+ "social.yahooapis.com\n"
+ "spoprod-a.akamaihd.net\n"
+ "staffhub.ms\n"
+ "staffhub.uservoice.com\n"
+ "svc.ms\n"
+ "sway.com\n"
+ "symcb.com\n"
+ "symcd.com\n"
+ "telemetryservice.firstpartyapps.oaspapps.com\n"
+ "trafficmanager.net\n"
+ "tse1.mm.bing.net\n"
+ "view.atdmt.com\n"
+ "wikipedia.firstpartyapps.oaspapps.com\n"
+ "windows.net\n\n\n"
+ "windowsupdate.com\n"
+ "wus-firstpartyapps.oaspapps.com\n"
+ "wus-www.sway-cdn.com\n"
+ "wus-www.sway-extensions.com\n"
+ "yammer.com\n"
+ "yammerusercontent.com\n";
final Pattern pattern = Pattern.compile(regex, Pattern.COMMENTS | Pattern.MULTILINE);
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