Horje
grepper valid base64 Code Example
grepper valid base64
// Check if string is Base64 encoded
// Source answer provided by: https://stackoverflow.com/users/549471/anders-marzi-tornblad

const b64Validator = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;

if(b64Validator.test(stringToTest) {
  // etc
}

// Explanation:
/*
    ^                          # Start of input
    ([0-9a-zA-Z+/]{4})*        # Groups of 4 valid characters decode
                               # to 24 bits of data for each group
    (                          # Either ending with:
        ([0-9a-zA-Z+/]{2}==)   # two valid characters followed by ==
        |                      # , or
        ([0-9a-zA-Z+/]{3}=)    # three valid characters followed by =
    )?                         # , or nothing
    $                          # End of input
*/




Javascript

Related
perfect scrollbar in textarea angular Code Example perfect scrollbar in textarea angular Code Example
disable submit button until checkbox is checked javascript Code Example disable submit button until checkbox is checked javascript Code Example
import jqueery vanilla js Code Example import jqueery vanilla js Code Example
generate random date in a range Code Example generate random date in a range Code Example
yarn react-redux Code Example yarn react-redux Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9