import Foundation
let pattern = ##"""
(?x-i) # FREE-SPACE MODE, case-sensitive
(?(DEFINE)
(?<ws>[\r\n\t\x20]*)
(?<str>"(?:\\[rntbf"\/] | [[:xdigit:]]{4} | [^\\"[:cntrl:]])*")
(?<bool>true|false)
(?<nil>nil)
(?<num>-?\d+(?:\.\d+)?)
(?<elem>(?:(?&str)|(?&bool)|(?&nil)|(?&num))(?&ws))
(?<comma>,(?&ws))
)
# JSON Array
\[ (?&ws)
(?:
(?:
(?&elem) | (?R)(?&ws)
)
(?(?=(?&comma)(?:(?&elem)|[\[\{]))(?&comma))
)*
\]
| # Or
# JSON Object
\{ (?&ws)
(?:
(?&str) (?&ws)
: (?&ws)
(?:
(?&elem) | (?R)(?&ws)
)
(?(?=(?&comma)["\[\{])(?&comma))
)*
\}
"""##
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = ##"""
{
"InstrumentationLogDateTime": "2018-06-28T13:49:33.7895781-04:00",
"property1": "00000000-1111-2222-3333-444444444444",
"property2": "00000000-1111-2222-3333-444444444444",
"property3": "my application",
"property4": "00000000-1111-2222-3333-444444444444",
"property5": "V0300",
"property6": "999918",
"property7": "system",
"property8": "Info",
"property9": "123456",
"property10": "xx",
"property11": "xx",
"property12": "page name",
"property13": "class name",
"property14": "method name",
"property15": "123456",
"property16": "123456",
"property17": 42,
"property18": "xx",
"property19": "xx",
"property20": "123456",
"property21": "trans name",
"property22": "42",
"property23": "2018-06-28T13:49:28",
"property24": "Object reference not set to an instance of an object.",
"property25": "<?xml version=\"1.0\" encoding=\"utf-16\"?><Error ServerName=\"xxxxxx\" DateTime=\"6/28/2018 1:49:33 PM\"><Message Description=\"Object reference not set to an instance of an object.\" Number=\"\" /><Methods><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"classname.xPSLayoutWidget\" Name=\"ProcessInstruction_DisplayFieldLabel\" LineNumber=\"42\"><Details><Detail Name=\"DisplayFieldLabel\" Description=\"Object reference not set to an instance of an object.\" /><Detail Name=\"Inner XML\" Description=\"\" /><Detail Name=\"fieldName\" Description=\"\" /><Detail Name=\"labelType\" Description=\"\" /><Detail Name=\"suppressColon\" Description=\"\" /><Detail Name=\"lengthAttr\" Description=\"\" /><Detail Name=\"mainLabel\" Description=\"Is Unknown\" /><Detail Name=\"subLabel\" Description=\"Is Unknown\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"classname.Widgets.xPSLayoutWidget\" Name=\"ProcessElement\" LineNumber=\"0\"><Details><Detail Name=\"ProcessElement\" Description=\"Object reference not set to an instance of an object.\" /><Detail Name=\"Inner XML\" Description=\"\" /><Detail Name=\"instructionName\" Description=\"xxxLayout:DisplayFieldLabel\" /></Details></Method><Method Dll=\"xxx.UI, Version=4.4.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"classname.otherstuff\" Name=\"ParseLayout\" LineNumber=\"0\" /><Method Dll=\"xxx.UI, Version=4.4.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"classname.LayoutParsers.xxxCoreLayoutParser\" Name=\"ParseLayout\" LineNumber=\"0\" /><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"classname.UI.Widgets.xPSLayoutWidget\" Name=\"ProcessInstruction_FieldEnumerator\" LineNumber=\"0\" /><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"classname.UI.Widgets.xPSLayoutWidget\" Name=\"ProcessElement\" LineNumber=\"0\"><Details><Detail Name=\"ProcessElement\" Description=\"Object reference not set to an instance of an object.\" /><Detail Name=\"Inner XML\" Description=\"<xxxLayout:Parameter Name="ShowAdjFields" Value="Y" xmlns:xxxLayout="urn:myuri.com:xxxLayout" /><xxxLayout:Parameter Name="DisplayLevel" Value="otherstuff" xmlns:xxxLayout="urn:myuri.com:xxxLayout" /><xxxLayout:Content xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content>\" /><Detail Name=\"instructionName\" Description=\"xxxLayout:FieldEnumerator\" /></Details></Method><Method Dll=\"xxx.UI, Version=4.4.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.xxx.LayoutParsers.xxxCoreLayoutParser\" Name=\"ParseLayout\" LineNumber=\"0\" /><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.xPSLayoutWidget\" Name=\"ProcessInstruction_GroupIterator\" LineNumber=\"0\"><Details><Detail Name=\"GroupIterator\" Description=\"Object reference not set to an instance of an object.\" /><Detail Name=\"Inner XML\" Description=\"<h2><xxxLayout:ShouldDisplayByRule Filter_RuleSetKey="Pxxxrv.anotherbiglongvalue" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><xxxLayout:True><xxxLayout:DisplayControl Name="rs_ind" FieldName="rs_ind" /> 
 </xxxLayout:True><xxxLayout:False><xxxLayout:DisplayFieldLabel FieldName="rs_ind" Class="internal" /></xxxLayout:False></xxxLayout:ShouldDisplayByRule></h2><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="anotherbiglongvalue" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="morestuffLevelCoverage_PremiumOnFirstLiabVehicle" /><xxxLayout:Parameter Name="IgnoreCoverages" Value="rs_pe_cnvrgd_fct" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="thingsthingsthings" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="morestuffLevelCoverage_PremiumOnAllLiabVehicles" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="anotherbiglongvalue" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="stuffstuffstuff" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator>\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.xPSLayoutWidget\" Name=\"ProcessElement\" LineNumber=\"0\"><Details><Detail Name=\"ProcessElement\" Description=\"Object reference not set to an instance of an object.\" /><Detail Name=\"Inner XML\" Description=\"<h2><xxxLayout:ShouldDisplayByRule Filter_RuleSetKey="Pxxxrv.CanProcessRateStability" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><xxxLayout:True><xxxLayout:DisplayControl Name="rs_ind" FieldName="rs_ind" /> 
 </xxxLayout:True><xxxLayout:False><xxxLayout:DisplayFieldLabel FieldName="rs_ind" Class="internal" /></xxxLayout:False></xxxLayout:ShouldDisplayByRule></h2><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="keykeykey" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="anotherbiglongvalue" /><xxxLayout:Parameter Name="IgnoreCoverages" Value="rs_pe_cnvrgd_fct" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="anotherbiglongvalue" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="morestuffLevelCoverage_anotherbiglongvalue" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="anotherbiglongvalue" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="VehicleLevelCoverage" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator>\" /><Detail Name=\"instructionName\" Description=\"xxxLayout:GroupIterator\" /></Details></Method><Method Dll=\"xxx.UI, Version=4.4.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.xxx.LayoutParsers.xxxCoreLayoutParser\" Name=\"ParseLayout\" LineNumber=\"0\" /><Method Dll=\"xxx.UI, Version=4.4.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.xxx.LayoutParsers.xxxCoreLayoutParser\" Name=\"ParseLayout\" LineNumber=\"0\" /><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.xPSLayoutWidget\" Name=\"ProcessInstruction_Layout\" LineNumber=\"0\" /><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.xPSLayoutWidget\" Name=\"ProcessElement\" LineNumber=\"0\"><Details><Detail Name=\"ProcessElement\" Description=\"Object reference not set to an instance of an object.\" /><Detail Name=\"Inner XML\" Description=\"<ul class="fieldList"><xxxLayout:GroupIterator Index="VehicleIndex" xmlns:xxxLayout="urn:otherstuff.com:xxxLayout"><h2><xxxLayout:ShouldDisplayByRule Filter_RuleSetKey="Pxxxrv.candothings"><xxxLayout:True><xxxLayout:DisplayControl Name="rs_ind" FieldName="rs_ind" /> 
 </xxxLayout:True><xxxLayout:False><xxxLayout:DisplayFieldLabel FieldName="rs_ind" Class="internal" /></xxxLayout:False></xxxLayout:ShouldDisplayByRule></h2><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="thingsandthings"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="morestuffLevelCoverage_PremiumOnFirstLiabVehicle" /><xxxLayout:Parameter Name="aparamparam" Value="rs_pe_cnvrgd_fct" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="anotherbiglongvalue"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="areallylongvalueofathing" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator><xxxLayout:FieldEnumerator FieldEnumerator_ObjectConfigKey="anotherbiglongvalue"><xxxLayout:Parameter Name="ShowAdjFields" Value="Y" /><xxxLayout:Parameter Name="DisplayLevel" Value="VehicleLevelCoverage" /><xxxLayout:Content><li><xxxLayout:DisplayFieldLabel LabelType="xxx" /><xxxLayout:DisplayControl /></li></xxxLayout:Content></xxxLayout:FieldEnumerator></xxxLayout:GroupIterator></ul>\" /><Detail Name=\"instructionName\" Description=\"xxxLayout:Layout\" /></Details></Method><Method Dll=\"xxx.UI, Version=4.4.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.xxx.LayoutParsers.xxxCoreLayoutParser\" Name=\"ParseLayout\" LineNumber=\"0\" /><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.xPSLayoutWidget\" Name=\"Build\" LineNumber=\"0\" /><Method Dll=\"xxx.UI, Version=4.4.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.xxx.WidgetManagers.xxxCoreWidgetManager\" Name=\"Build\" LineNumber=\"0\" /><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"DisplayWidget\" LineNumber=\"0\"><Details><Detail Name=\"Section\tName\" Description=\"more descriptions of things\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessDisplayItemInstruction\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:DisplayItem\" /><Detail Name=\"Level\" Description=\"0\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessInstruction\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:DisplayItem\" /><Detail Name=\"Level\" Description=\"8\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:DisplayItem\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessForEachItemInstruction\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:ForEachLayoutItem\" /><Detail Name=\"Level\" Description=\"7\" /><Detail Name=\"Layout\tItem Name\" Description=\"PageSections\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessInstruction\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:ForEachLayoutItem\" /><Detail Name=\"Level\" Description=\"7\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:ForEachLayoutItem\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessItemRepeaterInstruction\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:ItemRepeater\" /><Detail Name=\"Level\" Description=\"6\" /><Detail Name=\"Layout\tItem Name\" Description=\"PageSections\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessInstruction\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:ItemRepeater\" /><Detail Name=\"Level\" Description=\"6\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:ItemRepeater\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"form\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"div\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"div\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"body\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"html\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"ProcessNode\" LineNumber=\"0\"><Details><Detail Name=\"Node Name\" Description=\"xxxLayout:Layout\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"Build\" LineNumber=\"0\"><Details><Detail Name=\"Level\" Description=\"0\" /></Details></Method><Method Dll=\"PPUI.Widgets, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Widgets.UICoreLayoutManager\" Name=\"Build\" LineNumber=\"0\" /><Method Dll=\"xxx.UI, Version=4.4.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.xxx.Engine.xxxCoreEngine\" Name=\"DisplayPage\" LineNumber=\"0\"><Details><Detail Name=\"Page Name\" Description=\"more and more descriptions\" /></Details></Method><Method Dll=\"App_Web_ng11liaj, Version=0.0.0.0, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"ASP.scripts_displaypage_aspx\" Name=\"ExceptionRedirection\" LineNumber=\"0\"><Details><Detail Name=\"Url\" Description=\"http://intr-q-ppsu-004/xPS.Web/scripts/DisplayPage.aspx?Page=somepageinformation&Location=somewhere&UserId={blah blah blah}&OfferingId=anotherthing&transNum=&Act=funthings&AccessType=CallCtr&Brand=42&ContentGroup=V&Tab=NoTab\" /></Details></Method><Method Dll=\"PPUI.Utils, Version=0.18.1.1652, Culture=neutral, PublicKeyToken=__SECURITYMASK__\" Class=\"otherstuff.morestuff.UI.Utils.Log.ErrorLog\" Name=\"Log\" LineNumber=\"0\"><Details><Detail Name=\"ExceptionName\" Description=\"otherstuff.xxx.Exceptions.CustomException\" /><Detail Name=\"NestedInnerExceptionNames\" Description=\"System.NullReferenceException\" /><Detail Name=\"ExceptionLevelCount\" Description=\"1\" /><Detail Name=\"Url:\" Description=\"http://yepthisisauriofathing/scripts/DisplayPage.aspx?Page=thisisapagename&Location=aplace&UserId={duhduhduh}&OfferingId=yeahyeah&transNum=&Act=anotherbiglongvalue&AccessType=CallCtr&Brand=09&ContentGroup=V&Tab=NoTab\" /></Details></Method></Methods><InnerExceptionDetails><InnerExceptionDetail ExType=\"System.NullReferenceException\" ExSource=\"PPUI.Widgets\" ExTargetSite=\"ProcessInstruction_DisplayFieldLabel\" ExMessage=\"Object reference not set to an instance of an object.\"><ExCallStack CDATA=\" at otherstuff.morestuff.UI.Widgets.xPSLayoutWidget.ProcessInstruction_DisplayFieldLabel(PageControllerBase pageController, XmlNode node)\" /></InnerExceptionDetail></InnerExceptionDetails></Error>",
"CustomFields": {
"property26": "",
"property27": "xx",
"property28": "anotherbiglongvalue",
"property29": "xx",
"property31": "",
"property32": "123456",
"property33": "anotherbiglongvalue.anotherbiglongvalue.anotherbiglongvalue",
"property34": "anotherbiglongvalue,anotherbiglongvalue,anotherbiglongvalue",
"property35": "anotherbiglongvalueanotherbiglongvalueanotherbiglongvalue",
"property36": "this is a big ol thing",
"property37": "this is a big ol thing",
"property38": "this is a big ol thing",
"property39": "2018-06-28T13:49:33.0000000-04:00",
"property40": "2018-06-28T13:32:24.0000000-04:00"
}
}
"""##
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