RegEx for detecting base64 encoded strings

后端 未结 3 1843
慢半拍i
慢半拍i 2021-02-07 16:40

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:32

    try with:

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

    => RegEx to parse or validate Base64 data

提交回复
热议问题