c# - Validate string is base64 format using RegEx? -
How I validate the base 64 string and came on it.
^ (: [one-zA-Z0-9 + /] {4}?) * (: [One-zA-Z0-9 + /] {2} == | [ One-zA-Z0-9 + /] {3} =)? $
I also need a little help in allowing "==" as "=".
Thanks
This should be done very well.
Heeshets for private static reading & lt; Char & gt; 'A', 'B', 'C', 'D', 'A', 'A', 'E', 'F', 'G', 'H', 'I', 'J' H '' K ',' L ',' M ',' N ',' O ',' P ',' Q ',' R ',' S ',' T ',' U ',' V ' 'W', 'X', 'Y', 'Z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U' V ',' y ',' x ',' y ',' jade ',' 0 ',' 1 ',' 2 ',' 3 ',' 4 ',' 5 ',' 6 ',' 7 ' '8', '9', '+', '/', '='}; Public stable bool IsBase64String (string value) {if (string.IsNullOrEmptEx (value)) {return false; } And if (value any. (C => _base64 pigment. Compatible (C))) {return false; } Try {Convert.FromBase64String (value); Back true; } Hold (Format Exception) {return false; }}
Comments
Post a Comment