Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^\s*-----BEGIN PGP MESSAGE-----\s*(?:(Charset:.*\n)|(Version:.*\n)|(Comment:.*\n))*\s*(?:(?:[A-Za-z0-9+\/]{4}\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=))\n(?:=(?:[A-Za-z0-9+\/]{4}\n?)?)\s*-----END PGP MESSAGE-----\s$
/

Description

A Javascript regex for a PGP-encrypted message, including optional armor, valid headers, and checksum.

Submitted by Adroit - 9 months ago