Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(?P<file_number>\d+)\.\s+(?P<filepath>.*?)\n(?P<file_contents>```(.*?)```)(?=\d+\.\s+|$)
/
gms

Description

extract filename and contents

Submitted by anonymous - a year ago