dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.17k stars 4.72k forks source link

Regex bug: Unrecognized escape sequence \\Z #84576

Closed TahirAhmadov closed 1 year ago

TahirAhmadov commented 1 year ago

Description

Valid regex, recognized in other tools (such as Expresso) and previously worked in .NET 4.8, doesn't work in .NET 6.

Reproduction Steps

var rgx = new Regex(@"\A(?:(?:(?:(?:^)|(?:\A)|(?:\n))(?<Number>(?:\#(?<Number>\d+))|(?:\d+)|(?:\d+[A-Za-z]+)|(?:\d+-[A-Za-z]+)|(?:\d+(?:(?:\+)|(?:-)|(?:/)|(?:&)|(?:\ &\ ))\d+)|(?:Two)|(?:One)|(?:Zero))(?:(?: +)|(?:,)|(?:\.)|(?:\c\n))(?<Street>(?:(?i)A1A(?-i)(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i)))[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i)\s+(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i))))|(?:(?i)Avenue(?-i)\s+[A-Za-z])|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i) [A-Za-z][a-zA-Z\.]+(?: [A-Za-z][a-zA-Z\.]*)*?(?:\s+(?i)(?:(?:av)|(?:av\.)|(?:Avenue)|(?:ave)|(?:ave\.)|(?:Avenue)|(?:blvd)|(?:blvd\.)|(?:Boulevard)|(?:ctr)|(?:ctr\.)|(?:Center)|(?:cir)|(?:cir\.)|(?:Circle)|(?:tpke)|(?:tpke\.)|(?:Turnpike)|(?:cor)|(?:cor\.)|(?:Corner)|(?:ct)|(?:ct\.)|(?:Court)|(?:cres)|(?:cres\.)|(?:Crescent)|(?:xing)|(?:xing\.)|(?:Crossing)|(?:dr)|(?:dr\.)|(?:Drive)|(?:gdn)|(?:gdn\.)|(?:Garden)|(?:hts)|(?:hts\.)|(?:Heights)|(?:hwy)|(?:hwy\.)|(?:Highway)|(?:loop)|(?:loop\.)|(?:Loop)|(?:pkwy)|(?:pkwy\.)|(?:Parkway)|(?:prado)|(?:prado\.)|(?:Prado)|(?:plz)|(?:plz\.)|(?:Plaza)|(?:sq)|(?:sq\.)|(?:Square)|(?:ter)|(?:ter\.)|(?:Terrace)|(?:trce)|(?:trce\.)|(?:Terrace)|(?:rd)|(?:rd\.)|(?:Road)|(?:st)|(?:st\.)|(?:Street)|(?:trl)|(?:trl\.)|(?:Trail)|(?:way)|(?:way\.)|(?:Way)|(?:woods)|(?:woods\.)|(?:Woods))(?-i))*)|(?:[A-Za-z]+(?:-[a-zA-Z]+)+(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:[A-Za-z]\.?(?: [A-Za-z]\.?)*(?: [A-Za-z][a-zA-Z]+\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:[A-Za-z][a-zA-Z]+\.?(?: [A-Za-z][a-zA-Z]*\.?)*?(?:\s+(?i)(?:(?:av)|(?:av\.)|(?:Avenue)|(?:ave)|(?:ave\.)|(?:Avenue)|(?:blvd)|(?:blvd\.)|(?:Boulevard)|(?:ctr)|(?:ctr\.)|(?:Center)|(?:cir)|(?:cir\.)|(?:Circle)|(?:tpke)|(?:tpke\.)|(?:Turnpike)|(?:cor)|(?:cor\.)|(?:Corner)|(?:ct)|(?:ct\.)|(?:Court)|(?:cres)|(?:cres\.)|(?:Crescent)|(?:xing)|(?:xing\.)|(?:Crossing)|(?:dr)|(?:dr\.)|(?:Drive)|(?:gdn)|(?:gdn\.)|(?:Garden)|(?:hts)|(?:hts\.)|(?:Heights)|(?:hwy)|(?:hwy\.)|(?:Highway)|(?:loop)|(?:loop\.)|(?:Loop)|(?:pkwy)|(?:pkwy\.)|(?:Parkway)|(?:prado)|(?:prado\.)|(?:Prado)|(?:plz)|(?:plz\.)|(?:Plaza)|(?:sq)|(?:sq\.)|(?:Square)|(?:ter)|(?:ter\.)|(?:Terrace)|(?:trce)|(?:trce\.)|(?:Terrace)|(?:rd)|(?:rd\.)|(?:Road)|(?:st)|(?:st\.)|(?:Street)|(?:trl)|(?:trl\.)|(?:Trail)|(?:way)|(?:way\.)|(?:Way)|(?:woods)|(?:woods\.)|(?:Woods))(?-i))*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:\d+\s+[a-zA-Z]+[^,\c\n]+?)|(?:\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i)[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i)\s+\d+(?:(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i))?[^,\c\n]+))(?:(?: *(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *(?<Unit>[^\c\n,]+) *(?:\c\n[^\c]+)?(?:(?:\c\n)|(?:, )|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)|(?:(?=#))|(?:(?=Suite))) *(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *(?<Unit>(?:(?<!Highway )\d+)|(?:[A-Z]{1,2}\d{0,1} *-\d+)|(?:[A-Z]{3}-\d+)|(?:\d[0-9\-/A-Z]*)|(?:\d+ [A-Z]+ \d+)|(?:[A-Za-z]\d+[A-Za-z]?)|(?:[A-Z]{1,2})|(?:[a-z])) *(?:\c\n[^\c]+)?(?:(?:\c\n)|(?:, )|(?:\Z)))|(?: *(?:(?:-)|(?:/)|(?: )) *(?<Unit>(?:\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i) [Ff][Ll].*)|(?:(?:(?:Fl\.)|(?:Fl\ )).+))(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?<Unit>(?:(?:(?:[A-Z\-]+)|(?:farr))(?:(?:#)|(?: )|(?: #)|(?: - ))[0-9]+[A-Z0-9\-]*(?:\c\n[^\c]+)?)|(?:\d+ [A-Z]+ [IVX/]+)|(?:[A-Z]{4,5})|(?:[A-Z0-9]{3,4} *- *[A-Z0-9]{1,3})|(?:[A-Z]{3} *- *\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i) [Ff][Ll](?:oor)?)|(?:[A-Z]{1,3} *- *\d+ *- *\d+)|(?:[A-Z]{1,3} *- *\d+)|(?:[A-Z]{1,3} *\d+\.\d+[^\c]*)|(?:[A-Z]{1,3}\d+)|(?:[A-Z] ?(?:(?:-)|(?:&)|(?:/)) ?[A-Z])|(?:[0-9] ?(?:(?:-)|(?:&)|(?:/)) ?[0-9])|(?:[A-Z]{1,3}\d+ *- *\d+)|(?:[A-Z]{4} [A-Z][a-z]+ \d+)|(?:[A-Z]{4} (?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *\d+[A-Z]{0,2})|(?:[A-Z]{3}/[A-Z]-\d+)|(?:[A-Z][a-z]-\d+)|(?:[A-Z]\d[a-z])|(?:\d[a-z])|(?:[A-Z]{3})|(?:[a-z]\d{3}[a-z])|(?:[A-Z]{3} [A-Z]-\d+)|(?:\d+)|(?:[A-Z]{3} \d+/[A-Z][a-z]+)|(?:[A-Z]{4} \d+-(?:(?:South)|(?:North)|(?:East)|(?:West)))|(?:\d+ (?:(?:West)|(?:East)|(?:North)|(?:South)|(?:Hunnewell)))|(?:[A-Z]{3}-[A-Z]\d[^\c]+)|(?:[A-Z]{3} Building RM \d+)|(?:[A-Z]{3,4} Bldg *(?:/Fl \d)?)|(?:\d+ [A-Z][a-z]+ \d+ Mail Stop [A-Z0-9]+)|(?:[A-Z][a-z]*(?: (?:(?:N)))* (?:(?:Bldg)|(?:Bldg.)|(?:bldg.))[^\c]*)) *(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:,)|(?:/)|(?:--)|(?:-)|(?:;)|(?:(?<=(?:Ave\.)|(?:Street)) )) *(?<Unit>[A-Z][a-z]+(?:(?:(?: )|(?:,)|(?:, ))[A-Z][a-z]+)*(?:(?:#)|(?:# )|(?: )|(?:-)|(?:(?=\d)))(?:(?:\d+)|(?:[A-Z]\d+))(?:(?:[A-Z0-9]*)|(?:(?:(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i)))|(?:))(?:(?:(?:(?: )|(?:/)|(?:,)|(?:, ))[A-Za-z][a-z]+)|(?: So.)|(?:/(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) \d+[A-Z]*)|(?:)))(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:,)|(?:/)|(?:-)|(?: )) *(?<Unit>[Dd]ept[\. \-0-9a-zA-Z]+)(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:,)|(?:/)|(?: (?=Neville))) *(?<Unit>[A-Z][a-z]+ (?:(?:House)|(?:bldg.)|(?:bldg)|(?:Bldg.))(?: \d+)*)(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?<Unit>(?:(?:Bldg)|(?:Bldg\.))(?:(?:[# ]{0,2}\d+(?:(?:(?:(?: )|(?:, )|(?:-)|(?:- ))(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) ?\d+)|(?: \dfl\.)|(?:\c\n[^\c]+)|(?:)))|(?: [A-Z] [\d\.]+)|(?: One)))(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?<Unit>PO Box \d+)(?:(?:\c\n)|(?:\Z)))|(?:\c\n(?:(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i))? *(?<Unit>[^\c\n]+?)(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?<Unit>(?i)(?:(?:GNRL\.surgery)|(?:rad\.onc\.)|(?:Rad\.\ Dept\.)|(?:Rad\.\ Onc\.)|(?:Pathology)|(?:Radiology)|(?:Hospital)|(?:Neurosurgery)|(?:Brighton\ Marine\ Health\ Center)|(?:Cardiology)|(?:Pediatrics)|(?:MHBSS)|(?:Ortho\.\ Surg\.)|(?:CV\ Div)|(?:UMASS)|(?:MGH)|(?:Psychiatr)|(?:ObGyn\ Dept\.)|(?:[Aa]nesth)|(?:Radiation\ Oncology)|(?:Family\ Medicine\ Dept\.)|(?:OB/GYN)|(?:Rheumatology)|(?:Derm)|(?:Emerg)|(?:LMOB-GB)|(?:Nephrology\ Dept)|(?:Debby\ DiMartino)|(?:D\.\ DiMartino)|(?:central\ Plaza)|(?:Blood\ Bank)|(?:Critical)|(?:CV\ Division)|(?:ER\ Dept)|(?:Child\ &\ Fam\ Psych)|(?:Adult\ Medicine)|(?:Ophthalm))(?-i)[^\c]*(?:\c\n[^\c]+)?)(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:,\Z)|(?:\s*\Z)))))|(?:\s*(?i)(?:(?:PO)|(?:PO BOX)|(?:P OBox)|(?:P.  O. Box)|(?:P. O. Box)|(?:P.O Box)|(?:P.O.Box)|(?:P.O. Box)|(?:P.O. Drawer)|(?:P O Box))(?-i)\s+(?<POBox>[0-9\-]+)\s*))\Z\A(?:(?:(?:(?:^)|(?:\A)|(?:\n))(?<Number>(?:\#(?<Number>\d+))|(?:\d+)|(?:\d+[A-Za-z]+)|(?:\d+-[A-Za-z]+)|(?:\d+(?:(?:\+)|(?:-)|(?:/)|(?:&)|(?:\ &\ ))\d+)|(?:Two)|(?:One)|(?:Zero))(?:(?: +)|(?:,)|(?:\.)|(?:\c\n))(?<Street>(?:(?i)A1A(?-i)(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i)))[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i)\s+(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i))))|(?:(?i)Avenue(?-i)\s+[A-Za-z])|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i) [A-Za-z][a-zA-Z\.]+(?: [A-Za-z][a-zA-Z\.]*)*?(?:\s+(?i)(?:(?:av)|(?:av\.)|(?:Avenue)|(?:ave)|(?:ave\.)|(?:Avenue)|(?:blvd)|(?:blvd\.)|(?:Boulevard)|(?:ctr)|(?:ctr\.)|(?:Center)|(?:cir)|(?:cir\.)|(?:Circle)|(?:tpke)|(?:tpke\.)|(?:Turnpike)|(?:cor)|(?:cor\.)|(?:Corner)|(?:ct)|(?:ct\.)|(?:Court)|(?:cres)|(?:cres\.)|(?:Crescent)|(?:xing)|(?:xing\.)|(?:Crossing)|(?:dr)|(?:dr\.)|(?:Drive)|(?:gdn)|(?:gdn\.)|(?:Garden)|(?:hts)|(?:hts\.)|(?:Heights)|(?:hwy)|(?:hwy\.)|(?:Highway)|(?:loop)|(?:loop\.)|(?:Loop)|(?:pkwy)|(?:pkwy\.)|(?:Parkway)|(?:prado)|(?:prado\.)|(?:Prado)|(?:plz)|(?:plz\.)|(?:Plaza)|(?:sq)|(?:sq\.)|(?:Square)|(?:ter)|(?:ter\.)|(?:Terrace)|(?:trce)|(?:trce\.)|(?:Terrace)|(?:rd)|(?:rd\.)|(?:Road)|(?:st)|(?:st\.)|(?:Street)|(?:trl)|(?:trl\.)|(?:Trail)|(?:way)|(?:way\.)|(?:Way)|(?:woods)|(?:woods\.)|(?:Woods))(?-i))*)|(?:[A-Za-z]+(?:-[a-zA-Z]+)+(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:[A-Za-z]\.?(?: [A-Za-z]\.?)*(?: [A-Za-z][a-zA-Z]+\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:[A-Za-z][a-zA-Z]+\.?(?: [A-Za-z][a-zA-Z]*\.?)*?(?:\s+(?i)(?:(?:av)|(?:av\.)|(?:Avenue)|(?:ave)|(?:ave\.)|(?:Avenue)|(?:blvd)|(?:blvd\.)|(?:Boulevard)|(?:ctr)|(?:ctr\.)|(?:Center)|(?:cir)|(?:cir\.)|(?:Circle)|(?:tpke)|(?:tpke\.)|(?:Turnpike)|(?:cor)|(?:cor\.)|(?:Corner)|(?:ct)|(?:ct\.)|(?:Court)|(?:cres)|(?:cres\.)|(?:Crescent)|(?:xing)|(?:xing\.)|(?:Crossing)|(?:dr)|(?:dr\.)|(?:Drive)|(?:gdn)|(?:gdn\.)|(?:Garden)|(?:hts)|(?:hts\.)|(?:Heights)|(?:hwy)|(?:hwy\.)|(?:Highway)|(?:loop)|(?:loop\.)|(?:Loop)|(?:pkwy)|(?:pkwy\.)|(?:Parkway)|(?:prado)|(?:prado\.)|(?:Prado)|(?:plz)|(?:plz\.)|(?:Plaza)|(?:sq)|(?:sq\.)|(?:Square)|(?:ter)|(?:ter\.)|(?:Terrace)|(?:trce)|(?:trce\.)|(?:Terrace)|(?:rd)|(?:rd\.)|(?:Road)|(?:st)|(?:st\.)|(?:Street)|(?:trl)|(?:trl\.)|(?:Trail)|(?:way)|(?:way\.)|(?:Way)|(?:woods)|(?:woods\.)|(?:Woods))(?-i))*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:\d+\s+[a-zA-Z]+[^,\c\n]+?)|(?:\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i)[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i)\s+\d+(?:(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i))?[^,\c\n]+))(?:(?: *(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *(?<Unit>[^\c\n,]+) *(?:\c\n[^\c]+)?(?:(?:\c\n)|(?:, )|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)|(?:(?=#))|(?:(?=Suite))) *(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *(?<Unit>(?:(?<!Highway )\d+)|(?:[A-Z]{1,2}\d{0,1} *-\d+)|(?:[A-Z]{3}-\d+)|(?:\d[0-9\-/A-Z]*)|(?:\d+ [A-Z]+ \d+)|(?:[A-Za-z]\d+[A-Za-z]?)|(?:[A-Z]{1,2})|(?:[a-z])) *(?:\c\n[^\c]+)?(?:(?:\c\n)|(?:, )|(?:\Z)))|(?: *(?:(?:-)|(?:/)|(?: )) *(?<Unit>(?:\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i) [Ff][Ll].*)|(?:(?:(?:Fl\.)|(?:Fl\ )).+))(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?<Unit>(?:(?:(?:[A-Z\-]+)|(?:farr))(?:(?:#)|(?: )|(?: #)|(?: - ))[0-9]+[A-Z0-9\-]*(?:\c\n[^\c]+)?)|(?:\d+ [A-Z]+ [IVX/]+)|(?:[A-Z]{4,5})|(?:[A-Z0-9]{3,4} *- *[A-Z0-9]{1,3})|(?:[A-Z]{3} *- *\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i) [Ff][Ll](?:oor)?)|(?:[A-Z]{1,3} *- *\d+ *- *\d+)|(?:[A-Z]{1,3} *- *\d+)|(?:[A-Z]{1,3} *\d+\.\d+[^\c]*)|(?:[A-Z]{1,3}\d+)|(?:[A-Z] ?(?:(?:-)|(?:&)|(?:/)) ?[A-Z])|(?:[0-9] ?(?:(?:-)|(?:&)|(?:/)) ?[0-9])|(?:[A-Z]{1,3}\d+ *- *\d+)|(?:[A-Z]{4} [A-Z][a-z]+ \d+)|(?:[A-Z]{4} (?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *\d+[A-Z]{0,2})|(?:[A-Z]{3}/[A-Z]-\d+)|(?:[A-Z][a-z]-\d+)|(?:[A-Z]\d[a-z])|(?:\d[a-z])|(?:[A-Z]{3})|(?:[a-z]\d{3}[a-z])|(?:[A-Z]{3} [A-Z]-\d+)|(?:\d+)|(?:[A-Z]{3} \d+/[A-Z][a-z]+)|(?:[A-Z]{4} \d+-(?:(?:South)|(?:North)|(?:East)|(?:West)))|(?:\d+ (?:(?:West)|(?:East)|(?:North)|(?:South)|(?:Hunnewell)))|(?:[A-Z]{3}-[A-Z]\d[^\c]+)|(?:[A-Z]{3} Building RM \d+)|(?:[A-Z]{3,4} Bldg *(?:/Fl \d)?)|(?:\d+ [A-Z][a-z]+ \d+ Mail Stop [A-Z0-9]+)|(?:[A-Z][a-z]*(?: (?:(?:N)))* (?:(?:Bldg)|(?:Bldg.)|(?:bldg.))[^\c]*)) *(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:,)|(?:/)|(?:--)|(?:-)|(?:;)|(?:(?<=(?:Ave\.)|(?:Street)) )) *(?<Unit>[A-Z][a-z]+(?:(?:(?: )|(?:,)|(?:, ))[A-Z][a-z]+)*(?:(?:#)|(?:# )|(?: )|(?:-)|(?:(?=\d)))(?:(?:\d+)|(?:[A-Z]\d+))(?:(?:[A-Z0-9]*)|(?:(?:(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i)))|(?:))(?:(?:(?:(?: )|(?:/)|(?:,)|(?:, ))[A-Za-z][a-z]+)|(?: So.)|(?:/(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) \d+[A-Z]*)|(?:)))(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:,)|(?:/)|(?:-)|(?: )) *(?<Unit>[Dd]ept[\. \-0-9a-zA-Z]+)(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:,)|(?:/)|(?: (?=Neville))) *(?<Unit>[A-Z][a-z]+ (?:(?:House)|(?:bldg.)|(?:bldg)|(?:Bldg.))(?: \d+)*)(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?<Unit>(?:(?:Bldg)|(?:Bldg\.))(?:(?:[# ]{0,2}\d+(?:(?:(?:(?: )|(?:, )|(?:-)|(?:- ))(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) ?\d+)|(?: \dfl\.)|(?:\c\n[^\c]+)|(?:)))|(?: [A-Z] [\d\.]+)|(?: One)))(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?<Unit>PO Box \d+)(?:(?:\c\n)|(?:\Z)))|(?:\c\n(?:(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i))? *(?<Unit>[^\c\n]+?)(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?<Unit>(?i)(?:(?:GNRL\.surgery)|(?:rad\.onc\.)|(?:Rad\.\ Dept\.)|(?:Rad\.\ Onc\.)|(?:Pathology)|(?:Radiology)|(?:Hospital)|(?:Neurosurgery)|(?:Brighton\ Marine\ Health\ Center)|(?:Cardiology)|(?:Pediatrics)|(?:MHBSS)|(?:Ortho\.\ Surg\.)|(?:CV\ Div)|(?:UMASS)|(?:MGH)|(?:Psychiatr)|(?:ObGyn\ Dept\.)|(?:[Aa]nesth)|(?:Radiation\ Oncology)|(?:Family\ Medicine\ Dept\.)|(?:OB/GYN)|(?:Rheumatology)|(?:Derm)|(?:Emerg)|(?:LMOB-GB)|(?:Nephrology\ Dept)|(?:Debby\ DiMartino)|(?:D\.\ DiMartino)|(?:central\ Plaza)|(?:Blood\ Bank)|(?:Critical)|(?:CV\ Division)|(?:ER\ Dept)|(?:Child\ &\ Fam\ Psych)|(?:Adult\ Medicine)|(?:Ophthalm))(?-i)[^\c]*(?:\c\n[^\c]+)?)(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:,\Z)|(?:\s*\Z)))))|(?:\s*(?i)(?:(?:PO)|(?:PO BOX)|(?:P OBox)|(?:P.  O. Box)|(?:P. O. Box)|(?:P.O Box)|(?:P.O.Box)|(?:P.O. Box)|(?:P.O. Drawer)|(?:P O Box))(?-i)\s+(?<POBox>[0-9\-]+)\s*))\Z");

Expected behavior

Regex is created and is usable.

Actual behavior

System.Text.RegularExpressions.RegexParseException: 'Invalid pattern '..... SNIP .....' at offset 5467. Unrecognized escape sequence \\Z.'

Regression?

Used to work fine in .NET 4.8.

Known Workarounds

No response

Configuration

.NET 6, Windows 10, x64

Other information

No response

stephentoub commented 1 year ago

Used to work fine in .NET 4.8.

I just tried on .NET Framework 4.8 and I get this:

Unhandled Exception: System.ArgumentException: parsing "\A(?:(?:(?:(?:^)|(?:\A)|(?:\n))(?<Number>(?:\#(?<Number>\d+))|(?:\d+)|(?:\d+[A-Za-z]+)|(?:\d+-[A-Za-z]+)|(?:\d+(?:(?:\+)|(?:-)|(?:/)|(?:&)|(?:\ &\ ))\d+)|(?:Two)|(?:One)|(?:Zero))(?:(?: +)|(?:,)|(?:\.)|(?:\c\n))(?<Street>(?:(?i)A1A(?-i)(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i)))[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\...." - Unrecognized escape sequence \Z.
   at System.Text.RegularExpressions.RegexParser.ScanCharEscape()
   at System.Text.RegularExpressions.RegexParser.ScanCharClass(Boolean caseInsensitive, Boolean scanOnly)
   at System.Text.RegularExpressions.RegexParser.CountCaptures()
   at System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)
   at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, TimeSpan matchTimeout, Boolean useCache)
   at System.Text.RegularExpressions.Regex..ctor(String pattern)
stephentoub commented 1 year ago

recognized in other tools (such as Expresso)

Different languages have subtly different meanings for regular expressions. See https://arxiv.org/pdf/2105.04397.pdf for example.

I'm not seeing a bug here in .NET. The expression itself is buggy in its use of \c. There are a bunch of places where there's a \c that's not followed by a letter of a control character; that's illegal, and it leads to the parsing happening to blame the \Z that comes soon thereafter. If, for example, you search and replace in your pattern [^\c] with [^\cC], it'll parse.

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions See info in area-owners.md if you want to be subscribed.

Issue Details
### Description Valid regex, recognized in other tools (such as Expresso) and previously worked in .NET 4.8, doesn't work in .NET 6. ### Reproduction Steps ```cs var rgx = new Regex(@"\A(?:(?:(?:(?:^)|(?:\A)|(?:\n))(?(?:\#(?\d+))|(?:\d+)|(?:\d+[A-Za-z]+)|(?:\d+-[A-Za-z]+)|(?:\d+(?:(?:\+)|(?:-)|(?:/)|(?:&)|(?:\ &\ ))\d+)|(?:Two)|(?:One)|(?:Zero))(?:(?: +)|(?:,)|(?:\.)|(?:\c\n))(?(?:(?i)A1A(?-i)(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i)))[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i)\s+(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i))))|(?:(?i)Avenue(?-i)\s+[A-Za-z])|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i) [A-Za-z][a-zA-Z\.]+(?: [A-Za-z][a-zA-Z\.]*)*?(?:\s+(?i)(?:(?:av)|(?:av\.)|(?:Avenue)|(?:ave)|(?:ave\.)|(?:Avenue)|(?:blvd)|(?:blvd\.)|(?:Boulevard)|(?:ctr)|(?:ctr\.)|(?:Center)|(?:cir)|(?:cir\.)|(?:Circle)|(?:tpke)|(?:tpke\.)|(?:Turnpike)|(?:cor)|(?:cor\.)|(?:Corner)|(?:ct)|(?:ct\.)|(?:Court)|(?:cres)|(?:cres\.)|(?:Crescent)|(?:xing)|(?:xing\.)|(?:Crossing)|(?:dr)|(?:dr\.)|(?:Drive)|(?:gdn)|(?:gdn\.)|(?:Garden)|(?:hts)|(?:hts\.)|(?:Heights)|(?:hwy)|(?:hwy\.)|(?:Highway)|(?:loop)|(?:loop\.)|(?:Loop)|(?:pkwy)|(?:pkwy\.)|(?:Parkway)|(?:prado)|(?:prado\.)|(?:Prado)|(?:plz)|(?:plz\.)|(?:Plaza)|(?:sq)|(?:sq\.)|(?:Square)|(?:ter)|(?:ter\.)|(?:Terrace)|(?:trce)|(?:trce\.)|(?:Terrace)|(?:rd)|(?:rd\.)|(?:Road)|(?:st)|(?:st\.)|(?:Street)|(?:trl)|(?:trl\.)|(?:Trail)|(?:way)|(?:way\.)|(?:Way)|(?:woods)|(?:woods\.)|(?:Woods))(?-i))*)|(?:[A-Za-z]+(?:-[a-zA-Z]+)+(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:[A-Za-z]\.?(?: [A-Za-z]\.?)*(?: [A-Za-z][a-zA-Z]+\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:[A-Za-z][a-zA-Z]+\.?(?: [A-Za-z][a-zA-Z]*\.?)*?(?:\s+(?i)(?:(?:av)|(?:av\.)|(?:Avenue)|(?:ave)|(?:ave\.)|(?:Avenue)|(?:blvd)|(?:blvd\.)|(?:Boulevard)|(?:ctr)|(?:ctr\.)|(?:Center)|(?:cir)|(?:cir\.)|(?:Circle)|(?:tpke)|(?:tpke\.)|(?:Turnpike)|(?:cor)|(?:cor\.)|(?:Corner)|(?:ct)|(?:ct\.)|(?:Court)|(?:cres)|(?:cres\.)|(?:Crescent)|(?:xing)|(?:xing\.)|(?:Crossing)|(?:dr)|(?:dr\.)|(?:Drive)|(?:gdn)|(?:gdn\.)|(?:Garden)|(?:hts)|(?:hts\.)|(?:Heights)|(?:hwy)|(?:hwy\.)|(?:Highway)|(?:loop)|(?:loop\.)|(?:Loop)|(?:pkwy)|(?:pkwy\.)|(?:Parkway)|(?:prado)|(?:prado\.)|(?:Prado)|(?:plz)|(?:plz\.)|(?:Plaza)|(?:sq)|(?:sq\.)|(?:Square)|(?:ter)|(?:ter\.)|(?:Terrace)|(?:trce)|(?:trce\.)|(?:Terrace)|(?:rd)|(?:rd\.)|(?:Road)|(?:st)|(?:st\.)|(?:Street)|(?:trl)|(?:trl\.)|(?:Trail)|(?:way)|(?:way\.)|(?:Way)|(?:woods)|(?:woods\.)|(?:Woods))(?-i))*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:\d+\s+[a-zA-Z]+[^,\c\n]+?)|(?:\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i)[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i)\s+\d+(?:(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i))?[^,\c\n]+))(?:(?: *(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *(?[^\c\n,]+) *(?:\c\n[^\c]+)?(?:(?:\c\n)|(?:, )|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)|(?:(?=#))|(?:(?=Suite))) *(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *(?(?:(?(?:\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i) [Ff][Ll].*)|(?:(?:(?:Fl\.)|(?:Fl\ )).+))(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?(?:(?:(?:[A-Z\-]+)|(?:farr))(?:(?:#)|(?: )|(?: #)|(?: - ))[0-9]+[A-Z0-9\-]*(?:\c\n[^\c]+)?)|(?:\d+ [A-Z]+ [IVX/]+)|(?:[A-Z]{4,5})|(?:[A-Z0-9]{3,4} *- *[A-Z0-9]{1,3})|(?:[A-Z]{3} *- *\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i) [Ff][Ll](?:oor)?)|(?:[A-Z]{1,3} *- *\d+ *- *\d+)|(?:[A-Z]{1,3} *- *\d+)|(?:[A-Z]{1,3} *\d+\.\d+[^\c]*)|(?:[A-Z]{1,3}\d+)|(?:[A-Z] ?(?:(?:-)|(?:&)|(?:/)) ?[A-Z])|(?:[0-9] ?(?:(?:-)|(?:&)|(?:/)) ?[0-9])|(?:[A-Z]{1,3}\d+ *- *\d+)|(?:[A-Z]{4} [A-Z][a-z]+ \d+)|(?:[A-Z]{4} (?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *\d+[A-Z]{0,2})|(?:[A-Z]{3}/[A-Z]-\d+)|(?:[A-Z][a-z]-\d+)|(?:[A-Z]\d[a-z])|(?:\d[a-z])|(?:[A-Z]{3})|(?:[a-z]\d{3}[a-z])|(?:[A-Z]{3} [A-Z]-\d+)|(?:\d+)|(?:[A-Z]{3} \d+/[A-Z][a-z]+)|(?:[A-Z]{4} \d+-(?:(?:South)|(?:North)|(?:East)|(?:West)))|(?:\d+ (?:(?:West)|(?:East)|(?:North)|(?:South)|(?:Hunnewell)))|(?:[A-Z]{3}-[A-Z]\d[^\c]+)|(?:[A-Z]{3} Building RM \d+)|(?:[A-Z]{3,4} Bldg *(?:/Fl \d)?)|(?:\d+ [A-Z][a-z]+ \d+ Mail Stop [A-Z0-9]+)|(?:[A-Z][a-z]*(?: (?:(?:N)))* (?:(?:Bldg)|(?:Bldg.)|(?:bldg.))[^\c]*)) *(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:,)|(?:/)|(?:--)|(?:-)|(?:;)|(?:(?<=(?:Ave\.)|(?:Street)) )) *(?[A-Z][a-z]+(?:(?:(?: )|(?:,)|(?:, ))[A-Z][a-z]+)*(?:(?:#)|(?:# )|(?: )|(?:-)|(?:(?=\d)))(?:(?:\d+)|(?:[A-Z]\d+))(?:(?:[A-Z0-9]*)|(?:(?:(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i)))|(?:))(?:(?:(?:(?: )|(?:/)|(?:,)|(?:, ))[A-Za-z][a-z]+)|(?: So.)|(?:/(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) \d+[A-Z]*)|(?:)))(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:,)|(?:/)|(?:-)|(?: )) *(?[Dd]ept[\. \-0-9a-zA-Z]+)(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:,)|(?:/)|(?: (?=Neville))) *(?[A-Z][a-z]+ (?:(?:House)|(?:bldg.)|(?:bldg)|(?:Bldg.))(?: \d+)*)(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?(?:(?:Bldg)|(?:Bldg\.))(?:(?:[# ]{0,2}\d+(?:(?:(?:(?: )|(?:, )|(?:-)|(?:- ))(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) ?\d+)|(?: \dfl\.)|(?:\c\n[^\c]+)|(?:)))|(?: [A-Z] [\d\.]+)|(?: One)))(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?PO Box \d+)(?:(?:\c\n)|(?:\Z)))|(?:\c\n(?:(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i))? *(?[^\c\n]+?)(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?(?i)(?:(?:GNRL\.surgery)|(?:rad\.onc\.)|(?:Rad\.\ Dept\.)|(?:Rad\.\ Onc\.)|(?:Pathology)|(?:Radiology)|(?:Hospital)|(?:Neurosurgery)|(?:Brighton\ Marine\ Health\ Center)|(?:Cardiology)|(?:Pediatrics)|(?:MHBSS)|(?:Ortho\.\ Surg\.)|(?:CV\ Div)|(?:UMASS)|(?:MGH)|(?:Psychiatr)|(?:ObGyn\ Dept\.)|(?:[Aa]nesth)|(?:Radiation\ Oncology)|(?:Family\ Medicine\ Dept\.)|(?:OB/GYN)|(?:Rheumatology)|(?:Derm)|(?:Emerg)|(?:LMOB-GB)|(?:Nephrology\ Dept)|(?:Debby\ DiMartino)|(?:D\.\ DiMartino)|(?:central\ Plaza)|(?:Blood\ Bank)|(?:Critical)|(?:CV\ Division)|(?:ER\ Dept)|(?:Child\ &\ Fam\ Psych)|(?:Adult\ Medicine)|(?:Ophthalm))(?-i)[^\c]*(?:\c\n[^\c]+)?)(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:,\Z)|(?:\s*\Z)))))|(?:\s*(?i)(?:(?:PO)|(?:PO BOX)|(?:P OBox)|(?:P. O. Box)|(?:P. O. Box)|(?:P.O Box)|(?:P.O.Box)|(?:P.O. Box)|(?:P.O. Drawer)|(?:P O Box))(?-i)\s+(?[0-9\-]+)\s*))\Z\A(?:(?:(?:(?:^)|(?:\A)|(?:\n))(?(?:\#(?\d+))|(?:\d+)|(?:\d+[A-Za-z]+)|(?:\d+-[A-Za-z]+)|(?:\d+(?:(?:\+)|(?:-)|(?:/)|(?:&)|(?:\ &\ ))\d+)|(?:Two)|(?:One)|(?:Zero))(?:(?: +)|(?:,)|(?:\.)|(?:\c\n))(?(?:(?i)A1A(?-i)(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i)))[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i)\s+(?i)(?:(?:Historic highway )|(?:Highway )|(?:Hwy )|(?:Hwy.)|(?:Us Hwy )|(?:Us Highway )|(?:US-)|(?:US )|(?:County Rd )|(?:County Road )|(?:FL -)|(?:State Road )|(?:County Highway )|(?:State Highway )|(?:Ga Highway ))(?-i)(?:(?:\d+-\d+)|(?:\d+[aA])|(?:\d+)|(?:(?i)A1A(?-i))))|(?:(?i)Avenue(?-i)\s+[A-Za-z])|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i) [A-Za-z][a-zA-Z\.]+(?: [A-Za-z][a-zA-Z\.]*)*?(?:\s+(?i)(?:(?:av)|(?:av\.)|(?:Avenue)|(?:ave)|(?:ave\.)|(?:Avenue)|(?:blvd)|(?:blvd\.)|(?:Boulevard)|(?:ctr)|(?:ctr\.)|(?:Center)|(?:cir)|(?:cir\.)|(?:Circle)|(?:tpke)|(?:tpke\.)|(?:Turnpike)|(?:cor)|(?:cor\.)|(?:Corner)|(?:ct)|(?:ct\.)|(?:Court)|(?:cres)|(?:cres\.)|(?:Crescent)|(?:xing)|(?:xing\.)|(?:Crossing)|(?:dr)|(?:dr\.)|(?:Drive)|(?:gdn)|(?:gdn\.)|(?:Garden)|(?:hts)|(?:hts\.)|(?:Heights)|(?:hwy)|(?:hwy\.)|(?:Highway)|(?:loop)|(?:loop\.)|(?:Loop)|(?:pkwy)|(?:pkwy\.)|(?:Parkway)|(?:prado)|(?:prado\.)|(?:Prado)|(?:plz)|(?:plz\.)|(?:Plaza)|(?:sq)|(?:sq\.)|(?:Square)|(?:ter)|(?:ter\.)|(?:Terrace)|(?:trce)|(?:trce\.)|(?:Terrace)|(?:rd)|(?:rd\.)|(?:Road)|(?:st)|(?:st\.)|(?:Street)|(?:trl)|(?:trl\.)|(?:Trail)|(?:way)|(?:way\.)|(?:Way)|(?:woods)|(?:woods\.)|(?:Woods))(?-i))*)|(?:[A-Za-z]+(?:-[a-zA-Z]+)+(?: [A-Za-z][a-zA-Z]*\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:[A-Za-z]\.?(?: [A-Za-z]\.?)*(?: [A-Za-z][a-zA-Z]+\.?)*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:[A-Za-z][a-zA-Z]+\.?(?: [A-Za-z][a-zA-Z]*\.?)*?(?:\s+(?i)(?:(?:av)|(?:av\.)|(?:Avenue)|(?:ave)|(?:ave\.)|(?:Avenue)|(?:blvd)|(?:blvd\.)|(?:Boulevard)|(?:ctr)|(?:ctr\.)|(?:Center)|(?:cir)|(?:cir\.)|(?:Circle)|(?:tpke)|(?:tpke\.)|(?:Turnpike)|(?:cor)|(?:cor\.)|(?:Corner)|(?:ct)|(?:ct\.)|(?:Court)|(?:cres)|(?:cres\.)|(?:Crescent)|(?:xing)|(?:xing\.)|(?:Crossing)|(?:dr)|(?:dr\.)|(?:Drive)|(?:gdn)|(?:gdn\.)|(?:Garden)|(?:hts)|(?:hts\.)|(?:Heights)|(?:hwy)|(?:hwy\.)|(?:Highway)|(?:loop)|(?:loop\.)|(?:Loop)|(?:pkwy)|(?:pkwy\.)|(?:Parkway)|(?:prado)|(?:prado\.)|(?:Prado)|(?:plz)|(?:plz\.)|(?:Plaza)|(?:sq)|(?:sq\.)|(?:Square)|(?:ter)|(?:ter\.)|(?:Terrace)|(?:trce)|(?:trce\.)|(?:Terrace)|(?:rd)|(?:rd\.)|(?:Road)|(?:st)|(?:st\.)|(?:Street)|(?:trl)|(?:trl\.)|(?:Trail)|(?:way)|(?:way\.)|(?:Way)|(?:woods)|(?:woods\.)|(?:Woods))(?-i))*(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:\d+\s+[a-zA-Z]+[^,\c\n]+?)|(?:\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i)[^,\c\n]+?(?: *(?:(?:,)|(?:/)|(?:)) *(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i))?)|(?:(?i)(?:(?:N)|(?:N\.)|(?:North)|(?:S)|(?:S\.)|(?:South)|(?:E)|(?:E\.)|(?:East)|(?:W)|(?:W\.)|(?:West)|(?:NW)|(?:N\.W\.)|(?:Northwest)|(?:NE)|(?:N\.E\.)|(?:Northeast)|(?:SW)|(?:S\.W\.)|(?:Southwest)|(?:SE)|(?:S\.E\.)|(?:Southeast))(?-i)\s+\d+(?:(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i))?[^,\c\n]+))(?:(?: *(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *(?[^\c\n,]+) *(?:\c\n[^\c]+)?(?:(?:\c\n)|(?:, )|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)|(?:(?=#))|(?:(?=Suite))) *(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *(?(?:(?(?:\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i) [Ff][Ll].*)|(?:(?:(?:Fl\.)|(?:Fl\ )).+))(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?(?:(?:(?:[A-Z\-]+)|(?:farr))(?:(?:#)|(?: )|(?: #)|(?: - ))[0-9]+[A-Z0-9\-]*(?:\c\n[^\c]+)?)|(?:\d+ [A-Z]+ [IVX/]+)|(?:[A-Z]{4,5})|(?:[A-Z0-9]{3,4} *- *[A-Z0-9]{1,3})|(?:[A-Z]{3} *- *\d+(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i) [Ff][Ll](?:oor)?)|(?:[A-Z]{1,3} *- *\d+ *- *\d+)|(?:[A-Z]{1,3} *- *\d+)|(?:[A-Z]{1,3} *\d+\.\d+[^\c]*)|(?:[A-Z]{1,3}\d+)|(?:[A-Z] ?(?:(?:-)|(?:&)|(?:/)) ?[A-Z])|(?:[0-9] ?(?:(?:-)|(?:&)|(?:/)) ?[0-9])|(?:[A-Z]{1,3}\d+ *- *\d+)|(?:[A-Z]{4} [A-Z][a-z]+ \d+)|(?:[A-Z]{4} (?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) *\d+[A-Z]{0,2})|(?:[A-Z]{3}/[A-Z]-\d+)|(?:[A-Z][a-z]-\d+)|(?:[A-Z]\d[a-z])|(?:\d[a-z])|(?:[A-Z]{3})|(?:[a-z]\d{3}[a-z])|(?:[A-Z]{3} [A-Z]-\d+)|(?:\d+)|(?:[A-Z]{3} \d+/[A-Z][a-z]+)|(?:[A-Z]{4} \d+-(?:(?:South)|(?:North)|(?:East)|(?:West)))|(?:\d+ (?:(?:West)|(?:East)|(?:North)|(?:South)|(?:Hunnewell)))|(?:[A-Z]{3}-[A-Z]\d[^\c]+)|(?:[A-Z]{3} Building RM \d+)|(?:[A-Z]{3,4} Bldg *(?:/Fl \d)?)|(?:\d+ [A-Z][a-z]+ \d+ Mail Stop [A-Z0-9]+)|(?:[A-Z][a-z]*(?: (?:(?:N)))* (?:(?:Bldg)|(?:Bldg.)|(?:bldg.))[^\c]*)) *(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:,)|(?:/)|(?:--)|(?:-)|(?:;)|(?:(?<=(?:Ave\.)|(?:Street)) )) *(?[A-Z][a-z]+(?:(?:(?: )|(?:,)|(?:, ))[A-Z][a-z]+)*(?:(?:#)|(?:# )|(?: )|(?:-)|(?:(?=\d)))(?:(?:\d+)|(?:[A-Z]\d+))(?:(?:[A-Z0-9]*)|(?:(?:(?i)(?:(?:st)|(?:nd)|(?:rd)|(?:th))(?-i)))|(?:))(?:(?:(?:(?: )|(?:/)|(?:,)|(?:, ))[A-Za-z][a-z]+)|(?: So.)|(?:/(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) \d+[A-Z]*)|(?:)))(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:,)|(?:/)|(?:-)|(?: )) *(?[Dd]ept[\. \-0-9a-zA-Z]+)(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:,)|(?:/)|(?: (?=Neville))) *(?[A-Z][a-z]+ (?:(?:House)|(?:bldg.)|(?:bldg)|(?:Bldg.))(?: \d+)*)(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?(?:(?:Bldg)|(?:Bldg\.))(?:(?:[# ]{0,2}\d+(?:(?:(?:(?: )|(?:, )|(?:-)|(?:- ))(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i) ?\d+)|(?: \dfl\.)|(?:\c\n[^\c]+)|(?:)))|(?: [A-Z] [\d\.]+)|(?: One)))(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?PO Box \d+)(?:(?:\c\n)|(?:\Z)))|(?:\c\n(?:(?i)(?:(?:ste(?![a-zA-Z]))|(?:ste\#)|(?:ste\ \#)|(?:ste\.\ \#)|(?:ste\.)|(?:suite)|(?:ut)|(?:suite\#)|(?:siute)|(?:suit)|(?:unit)|(?:room)|(?:apt(?![a-zA-Z]))|(?:apt\#)|(?:apt\ \#)|(?:apt\.\ \#)|(?:apt\.)|(?:number(?![a-z]))|(?:box(?![a-z]))|(?:rm(?![a-z]))|(?:bx(?![a-z]))|(?:mail stop)|(?:Mail Stop)|(?:\#))(?-i))? *(?[^\c\n]+?)(?:(?:\c\n)|(?:\Z)))|(?: *(?:(?:-)|(?:--)|(?:/)|(?: )|(?:\.)|(?:,)) *(?(?i)(?:(?:GNRL\.surgery)|(?:rad\.onc\.)|(?:Rad\.\ Dept\.)|(?:Rad\.\ Onc\.)|(?:Pathology)|(?:Radiology)|(?:Hospital)|(?:Neurosurgery)|(?:Brighton\ Marine\ Health\ Center)|(?:Cardiology)|(?:Pediatrics)|(?:MHBSS)|(?:Ortho\.\ Surg\.)|(?:CV\ Div)|(?:UMASS)|(?:MGH)|(?:Psychiatr)|(?:ObGyn\ Dept\.)|(?:[Aa]nesth)|(?:Radiation\ Oncology)|(?:Family\ Medicine\ Dept\.)|(?:OB/GYN)|(?:Rheumatology)|(?:Derm)|(?:Emerg)|(?:LMOB-GB)|(?:Nephrology\ Dept)|(?:Debby\ DiMartino)|(?:D\.\ DiMartino)|(?:central\ Plaza)|(?:Blood\ Bank)|(?:Critical)|(?:CV\ Division)|(?:ER\ Dept)|(?:Child\ &\ Fam\ Psych)|(?:Adult\ Medicine)|(?:Ophthalm))(?-i)[^\c]*(?:\c\n[^\c]+)?)(?:(?:\c\n)|(?:\Z)))|(?:(?:(?:,\Z)|(?:\s*\Z)))))|(?:\s*(?i)(?:(?:PO)|(?:PO BOX)|(?:P OBox)|(?:P. O. Box)|(?:P. O. Box)|(?:P.O Box)|(?:P.O.Box)|(?:P.O. Box)|(?:P.O. Drawer)|(?:P O Box))(?-i)\s+(?[0-9\-]+)\s*))\Z"); ``` ### Expected behavior Regex is created and is usable. ### Actual behavior ``` System.Text.RegularExpressions.RegexParseException: 'Invalid pattern '..... SNIP .....' at offset 5467. Unrecognized escape sequence \\Z.' ``` ### Regression? Used to work fine in .NET 4.8. ### Known Workarounds _No response_ ### Configuration .NET 6, Windows 10, x64 ### Other information _No response_
Author: TahirAhmadov
Assignees: -
Labels: `area-System.Text.RegularExpressions`, `untriaged`
Milestone: -
ghost commented 1 year ago

This issue has been marked needs-author-action and may be missing some important information.

TahirAhmadov commented 1 year ago

Hahaha I figured it out. It's actually a Visual Studio bug. What happened was, the class containing this static readonly regex also contains a method, and in that method I performed a symbol rename operation from r to c. I then tested unrelated functionality and experienced this exception. I thought it was odd that the static readonly initializers suddenly started breaking, but figured it must have been some kind of optimization where those initializers didn't run previously due to some other circumstances. Actually, the symbol rename also changed a whole bunch of strings. I do have the Include strings option checked in symbol rename popup, but the symbol in question was a LINQ lambda parameter, and these regexes are static readonly fields. I would think those should not be included because they are outside the scope of the lambda?

stephentoub commented 1 year ago

I would think those should not be included because they are outside the scope of the lambda?

That'd be a question for dotnet/roslyn.

Thanks.

TahirAhmadov commented 1 year ago

Thank you!