Regular expression for matching base64 encoded strings
$ npm install --save base64-regex
const base64Regex = require('base64-regex');
base64Regex().test('dW5pY29ybg== foo bar');
//=> true
base64Regex({exact: true}).test('dW5pY29ybg== foo bar');
//=> false
base64Regex({exact: true}).test('dW5pY29ybg==');
//=> true
'foo dW5pY29ybg== bar Ym9hdA=='.match(base64Regex());
//=> ['dW5pY29ybg==', 'Ym9hdA==']
Returns a regex for matching base64 encoded strings.
Type: boolean
Default: false
(Matches any base64 in a string)
Only match an exact string. Useful with RegExp#test
to check if a string is a base64 encoded string.
MIT © Kevin Mårtensson