Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(?ms)(\s*((?<privatekey>-----BEGIN .* PRIVATE KEY-----.*?-----END .* PRIVATE KEY-----)|(?<certificate>-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----))\s*){2}
/
gm

Description

Identify and group Certificate and Private Key from a combination PEM file

Submitted by @rbleattler - 2 years ago