RegEx for detecting base64 encoded strings

后端 未结 3 1871
北荒
北荒 2021-02-07 16:26

I need to detect strings with the form @base64 (e.g. @VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==) in my application.

The @ has to be at the begin

3条回答
  •  無奈伤痛
    2021-02-07 17:27

    try with:

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

    => RegEx to parse or validate Base64 data

提交回复
热议问题