Regular Expressions 101

Validate Base64 with new lines (e.g. GPG base64 messages)

Open Workspace
  • PCRE (Legacy)
  • Match
3

Regular Expression

/
(?:^(?:[A-Za-z0-9+\/]{4}\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$)
/

Description

This regular expression validates if given string is formatted in Base64, additional it accepts new lines, since payload can have new lines in it.

Submitted by wpodgorski