base64-regex

v1.1.0
Regular expression for matching base64 encoded strings
base64 regex string

base64-regex Build Status

Regular expression for matching base64 encoded strings

Install

$ npm install --save base64-regex

Usage

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==']

API

base64Regex([options])

Returns a regex for matching base64 encoded strings.

options

exact

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.

License

MIT © Kevin Mårtensson

Metadata

  • MIT
  • >=0.10.0
  • Kevin Mårtensson
  • released 11/27/2014

Downloads

Maintainers