const regex = /.*?UserID="(?<UserID>.*?)".*?UserName="(?<UserName>.*?)".*?NetworkAccessPointID="(?<IPAddress>.*?)".*?EventDateTime="(?<DateTime>.*?)".*?EventOutcomeIndicator="(?<OutcomeIndicator>.*?)".*?csd-code="(?<csd_code>.*?)".*?AuditEnterpriseSiteID="(?<Site>.*?)".*?ParticipantObjectID="(?<PatientID>.*?)".*?ParticipantObjectTypeCode="(?<ObjectTypeCode>.*?)".*?/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('.*?UserID="(?<UserID>.*?)".*?UserName="(?<UserName>.*?)".*?NetworkAccessPointID="(?<IPAddress>.*?)".*?EventDateTime="(?<DateTime>.*?)".*?EventOutcomeIndicator="(?<OutcomeIndicator>.*?)".*?csd-code="(?<csd_code>.*?)".*?AuditEnterpriseSiteID="(?<Site>.*?)".*?ParticipantObjectID="(?<PatientID>.*?)".*?ParticipantObjectTypeCode="(?<ObjectTypeCode>.*?)".*?', '')
const str = `<AuditMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ActiveParticipant UserID="10361" UserIsRequestor="true" UserName="Alexander Hardin" NetworkAccessPointID="184.190.165.174" NetworkAccessPointTypeCode="2" />
<EventIdentification EventDateTime="2022-08-15T04:26:37+0000" EventOutcomeIndicator="0" EventActionCode="R">
<EventID codeSystemName="DCM" csd-code="110110" originalText="Patient Record" />
</EventIdentification>
<AuditSourceIdentification AuditSourceID="Carepointe" AuditEnterpriseSiteID="AZ" />
<ParticipantObjectIdentification ParticipantObjectID="" ParticipantObjectTypeCodeRole="1" ParticipantObjectTypeCode="1" ParticipantObjectDataLifeCycle="6">
<ParticipantObjectIDTypeCode>2</ParticipantObjectIDTypeCode>
<ParticipantObjectQuery>U0VMRUNUIFVzZXJfSUQsIEZpcnN0TmFtZSwgTGFzdE5hbWUsIENvbXBhbnksIFJvbGVfSUQgRlJPTSB0YmxfdXNlcnMgV0hFUkUgVXNlcl9JRCA9IDp1aWQ=</ParticipantObjectQuery>
<ParticipantObjectDetail type="User_ID" value="MTAzNjE=" />
</ParticipantObjectIdentification>
<DICOMObjectDescriptionContents>
<Anonymized>0</Anonymized>
<Encrypted>0</Encrypted>
</DICOMObjectDescriptionContents>
</AuditMessage>`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions