import Foundation
let pattern = #" "name": "(.+)",(.*)|"endpoint": "(.*\..*)","#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
"name": "Arkane Network",
"endpoint": "app.arkane.network ",
"endpoint": "connect.arkane.network ",
"endpoint": "login.arkane.network",
"name": "Bpost2",
"endpoint": "*.bpost2.be",
"name": "Brussels Airlines",
"endpoint": "bprofile.brusselsairlines.com",
"endpoint": "www.brusselsairlines.com",
"name": "De Morgen",
"endpoint": "*.demorgen.be",
"endpoint": "abonnement.demorgen.be",
"endpoint": "login2.demorgen.be",
"endpoint": "myaccount.demorgen.be",
"endpoint": "shop.demorgen.be",
"endpoint": "www.demorgen.be",
"name": "Delen Private Bank",
"endpoint": "api.digital.delen.be ",
"endpoint": "api.digital.delen.lu ",
"endpoint": "app.delen.be ",
"endpoint": "app.delen.ch ",
"endpoint": "app.delen.lu ",
"endpoint": "auth.digital.delen.be ",
"endpoint": "auth.digital.delen.lu ",
"endpoint": "be.delen.digital",
"endpoint": "login.delen.be ",
"endpoint": "login.delen.ch ",
"endpoint": "login.delen.lu ",
"endpoint": "login.oyens.com",
"endpoint": "status.delen.be ",
"endpoint": "sts.delen.be ",
"endpoint": "www.cadelam.be ",
"endpoint": "www.cadelux.lu/en ",
"endpoint": "www.delen.be/en ",
"name": "EURid",
"endpoint": "*.das.eu",
"endpoint": "*.dns.eu",
"endpoint": "*.eurid.eu",
"endpoint": "*.nic.eu",
"endpoint": "*.registry.eu",
"endpoint": "*.whois.eu",
"name": "GULP",
"endpoint": "www.gulp-shop.de",
"endpoint": "*.gulp.ch",
"endpoint": "*.gulp.de",
"endpoint": "demo.tendertracker.de",
"name": "Hardware Info",
"endpoint": " *.hardware.info ",
"endpoint": "*.hwigroup.com",
"endpoint": "*.hwigroup.net ",
"name": "Hoplr",
"endpoint": "www.hoplr.com",
"endpoint": "*.hoplr.*",
"endpoint": "com.hoplr",
"name": "IAM KU Leuven",
"endpoint": " account.kuleuven.be",
"endpoint": " idp.kuleuven.be",
"name": "Jooki",
"endpoint": "*.jooki.rocks",
"endpoint": "*.muuselabs.com",
"endpoint": "my.jooki.rocks",
"name": "KU Leuven - www.kuleuven.be",
"endpoint": "www.kuleuven.be/english/",
"endpoint": "www.kuleuven.be",
"name": "Monster Worldwide",
"endpoint": "*.military.com",
"endpoint": "*.monster.at",
"endpoint": "*.monster.be",
"endpoint": "*.monster.ca",
"endpoint": "*.monster.ch",
"endpoint": "*.monster.co.uk",
"endpoint": "*.monster.com",
"endpoint": "*.monster.cz",
"endpoint": "*.monster.de",
"endpoint": "*.monster.dk",
"endpoint": "*.monster.es",
"endpoint": "*.monster.eu",
"endpoint": "*.monster.fi",
"endpoint": "*.monster.fr",
"endpoint": "*.monster.hu",
"endpoint": "*.monster.ie",
"endpoint": "*.monster.it",
"endpoint": "*.monster.lu",
"endpoint": "*.monster.no",
"endpoint": "*.monster.pt",
"endpoint": "*.monster.se",
"endpoint": "*.monsterboard.nl",
"endpoint": "*.monsterpolska.pl",
"name": "Nexuzhealth",
"endpoint": "mobile.nexuzhealth.be",
"endpoint": "mynexuz.be",
"endpoint": "mynexuz.be/myUZ/",
"endpoint": "www.nexuzhealth.be/en",
"name": "Nexuzhealth Web PACS",
"endpoint": " idp-contact.nexuzhealth.be",
"endpoint": "media.nexuzhealth.be/patient/ ",
"name": "Online enrollment for students",
"endpoint": "https://associatie.kuleuven.be/inschrijvingen/oli_login_50000050",
"endpoint": "https://webwsp.aps.kuleuven.be/sap/bc/ui5_ui5/sap/zc_oi_appl/",
"name": "Phished",
"endpoint": "*.phished.be",
"name": "Port of Antwerp",
"endpoint": "*.c-point.be",
"endpoint": "*.portofantwerp.com",
"name": "Randstad",
"endpoint": "*.randstadrisesmart.*",
"endpoint": "*.risesmart.*",
"endpoint": "*.randstad.*",
,
"name": "Red Bull",
"endpoint": "*.redbull.com",
"name": "Sentiance",
"endpoint": "*.sentiance.com",
"endpoint": "docs.sentiance.com",
"name": "Speakap Responsible Disclosure",
"endpoint": "*.speakap.com",
"endpoint": "*.speakap.io",
"name": "Suivo",
"endpoint": " aweb.suivo.com",
"endpoint": "asupport.suivo.com",
"name": "Telenet - Base ",
"endpoint": "https://www2.telenet.be/nl/landing-pages/safespot",
"endpoint": "*.9lives.be",
"endpoint": "*.base.be",
"endpoint": "*.telenet.be",
"endpoint": "*.telenethotspot.be ",
"endpoint": "*.yelo.be",
"endpoint": "*.yeloplay.be",
"name": "Tempo-Team ",
"endpoint": "www.tempo-team.com",
"endpoint": "www.tempo-team.nl",
"endpoint": "www.tempo-team.be",
"endpoint": "*.tempo-team.*",
"name": "Tomorrowland",
"endpoint": "artists.tomorrowland.com/production-website/33117",
"endpoint": "cognito-idp.eu-west-1.amazonaws.com",
"endpoint": "globaljourney.tomorrowland.com",
"endpoint": "mdm.weareone.world",
"endpoint": "my.tomorrowland.com",
"endpoint": "oneworldradio.tomorrowland.com",
"endpoint": "sp1y1tpaf1.execute-api.eu-west-1.amazonaws.com",
"endpoint": "winterpackages.tomorrowland.com",
"endpoint": "www.tomorrowland.com",
"name": "Torfs",
"endpoint": "winkels.torfs.be",
"endpoint": "www.schoenentorfs.be",
"endpoint": "www.schoenentorfs.nl ",
"endpoint": "www.torfs.be",
"endpoint": "www.torfs.nl",
"endpoint": "www.samenfittorfs.be",
"endpoint": "www.sterkinjeschoenen.be",
"endpoint": "www.torfssuppliers.be",
"name": "Trouw",
"endpoint": "*.trouw.nl",
"endpoint": "abonnement.trouw.nl",
"endpoint": "login2.trouw.nl",
"endpoint": "myaccount.trouw.nl",
"endpoint": "shop.trouw.nl",
"endpoint": "webwinkel.trouw.nl",
"endpoint": "www.trouw.nl",
"name": "Twago",
"endpoint": "*.twago.fr",
"endpoint": "*.twago.it",
"endpoint": "*.twago.com",
"endpoint": "*.twago.de",
"endpoint": "*.twago.es",
"name": "Tweakers",
"endpoint": "*.tweakblogs.net",
"endpoint": "*.tweakers.net",
"endpoint": "*.tweakimg.net",
"name": "UZ Leuven",
"endpoint": "www.uzleuven.be/en",
"name": "VRT",
"endpoint": "*.canvas.be",
"endpoint": "*.dewarmsteweek.be",
"endpoint": "*.een.be",
"endpoint": "*.ketnet.be",
"endpoint": "*.klara.be",
"endpoint": "*.mnm.be",
"endpoint": "*.radio1.be",
"endpoint": "*.radio2.be",
"endpoint": "*.sporza.be",
"endpoint": "*.stubru.be",
"endpoint": "*.vrt.be",
"endpoint": "be.vrt.ketnet.ketnet",
"name": "VTM GO",
"endpoint": "login2.vtm.be",
"endpoint": "myaccount.vtm.be",
"endpoint": "vtm.be/vtmgo",
"endpoint": "vtmgo.be",
"endpoint": "*.vtm.be",
"endpoint": "*.vtmgo.be",
"name": "eHealth Hub VZN KUL",
"endpoint": "hub.vznkul.be/services/intrahub/IntraHubService",
"endpoint": "hub.vznkul.be/services/interhub/InterHubService",
"endpoint": "hubacc.vznkul.be/services/acceptance/intrahub/IntraHubService",
"endpoint": "hubacc.vznkul.be/services/acceptance/interhub/InterHubService",
"endpoint": "hub.vznkul.be/* ",
"endpoint": "hubacc.vznkul.be/*",
"name": "iBOOD.com",
"endpoint": "www.ibood.com",
"name": "intigriti",
"endpoint": "*.intigriti.com",
"endpoint": "*.intigriti.io",
"endpoint": "*.intigriti.me",
"name": "itsme",
"endpoint": "mobileapp.itsme.be",
"endpoint": "business.itsme.be/en/",
"endpoint": "confluence.belgianmobileid.be",
"endpoint": "crowd.belgianmobileid.be",
"endpoint": "jira.belgianmobileid.be",
"endpoint": "merchant.itsme.be",
"endpoint": "my.itsme.be",
"endpoint": "www.belgianmobileid.be/en/",
"endpoint": "www.itsme.be/en/",
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let matches = regex.matches(in: testString, range: stringRange)
var result: [[String]] = []
for match in matches {
var groups: [String] = []
for rangeIndex in 1 ..< match.numberOfRanges {
let nsRange = match.range(at: rangeIndex)
guard !NSEqualRanges(nsRange, NSMakeRange(NSNotFound, 0)) else { continue }
let string = (testString as NSString).substring(with: nsRange)
groups.append(string)
}
if !groups.isEmpty {
result.append(groups)
}
}
print(result)
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 Swift 5.2, please visit: https://developer.apple.com/documentation/foundation/nsregularexpression