#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(Policy Number:\s*)([A-Z0-9]+)(?=\s*Plan Eff\. Date:)"
Local $sString = "OBX|1|FT|ED Fin||\.br\Butler Memorial Hospital Emergency Department\.br\\.br\One Hospital Way\.br\\.br\Butler, PA, 16001\.br\\.br\7242836666\.br\\.br\Patient: UPMC TEST DOB: 1/1/1945\.br\\.br\MR #: 200115 Age/Gender: 70y F\.br\\.br\DOS: 11/27/2015 08:15 Acct #: 20005591\.br\\.br\Private Phys: ED Phys:\.br\\.br\CHIEF COMPLAINT: Enc. Type: ACUITY:\.br\\.br\******** Initial Acuity unassigned\.br\\.br\Insurance\.br\\.br\1. Insurer Details\.br\\.br\Name: Relationship: SELF\.br\\.br\SSN: Employer Name:\.br\\.br\Sex:\.br\\.br\Insurance Type: UPMC HEALTH PLAN Plan Id: CPUPMC\.br\\.br\Policy Number: DKJSLFLSF Plan Eff. Date:\.br\\.br\Group Name: Group Number:\.br\\.br\Company Name: UPMC HEALTH PLAN Priority: 1\.br\\.br\Billing Status: Verify Indicator:\.br\\.br\TRIAGE\.br\\.br\Arrival: Patient arrived walking via car/private vehicle from home accompanied\.br\by parent(s) < KAL1 11/27/2015 08:24>\.br\\.br\Pain Level: Patient's pain is a 2 using a Wong-Baker scale. < KAL1 11/27/2015\.br\08:25>\.br\\.br\Patient not currently taking any medications.\.br\< KAL1 11/27/2015 08:25>\.br\\.br\Medical and surgical history obtained. <KAL1 11/27/15 08:25 >\.br\\.br\Patient states no travel to West Africa nor had contact with any person that\.br\has traveled to West Africa in the 21 days before illness onset. <KAL1\.br\11/27/2015 08:24>\.br\\.br\ALLERGIES\.br\\.br\+---------------------+--------------------+--------+------------------------+\.br\\F\Allergen \F\Status \F\Comments\F\Updated \F\\.br\\F\Reaction \F\ \F\ \F\ \F\\.br\+---------------------+--------------------+--------+------------------------+\.br\\F\*No Known Allergies* \F\Confirmed or \F\ \F\<KAL1 Nov 27 2015 \F\\.br\\F\ \F\verified \F\ \F\8:25AM> \F\\.br\+---------------------+--------------------+--------+------------------------+\.br\Patient not currently taking any medications.\.br\< KAL1 11/27/2015 08:25>\.br\\.br\HOME MEDICATIONS\.br\\.br\+-----------------------+----------+------+--------+-------------------------+\.br\\F\Medication Name \F\Last Dose \F\Status\F\Comments\F\Updated \F\\.br\\F\Instructions \F\Taken Date\F\ \F\ \F\ \F\\.br\+-----------------------+----------+------+--------+-------------------------+\.br\\F\*Not Taking Home Meds* \F\ \F\Active\F\ \F\<KAL1 Nov 27 2015 8:25AM>\F\\.br\+-----------------------+----------+------+--------+-------------------------+\.br\PAST MEDICAL / SURGICAL / SOCIAL HISTORY\.br\\.br\Smoking Status: Never smoked\.br\< KAL1 11/27/2015 08:25>\.br\\.br\No relevant surgeries.\.br\< KAL1 11/27/2015 08:26>\.br\\.br\DISPOSITION\.br\\.br\Nursing\.br\\.br\Disposition is Discharged - Routine\.br\< KAL1 11/27/2015 08:26>\.br\\.br\Family not notified of patient's disposition. <KAL1 11/27/15 08:26 >\.br\\.br\------------------------------------------------------------------------------\.br\\.br\Bed Assignments:\.br\\.br\MainWR INU 11/27/2015 08:15\.br\\.br\Status Activity:\.br\\.br\With Triage RN INU 11/27/2015 08:15\.br\\.br\Released KAL1 11/27/2015 08:28\.br\\.br\Acuity Activity:\.br\\.br\Acuity unassigned INU 11/27/2015 08:15\.br\\.br\Chart Documented By:\.br\\.br\KAL1: KALLIE TEST SIMMONS\.br\\.br\Release Information:\.br\\.br\Patient released 11/27/2015 08:28\.br\\.br\Released by KALLIE TEST SIMMONS\.br\\.br\Printed By User N. Interface on 11/27/2015 8:30 AM\.br\\.br\Medical Chart\.br\\.br\||||||S|"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH)
; Present the entire match result
_ArrayDisplay($aArray, "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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm