Regular Expressions 101

Community Patterns

Repeating Group

1

Regular Expression
PCRE (PHP <7.3)

/
(?=NM1\*03\*1\*).*?~((REF\*(?<refDepCode>\w{2,3})\*(?<refDepVal>.*?)~)*)
/
gms

Description

There are 2 segments within this data that start with REF* and end with a tilde (~). I can capture one of them but not both. I've read and cant seem to figure this one out. I DO need to preface with the NM1*03 piece.

Submitted by Chris. - 9 years ago