All Projects → kevva → base64-regex

kevva / base64-regex

Licence: MIT License
Regular expression for matching base64 encoded strings

Programming Languages

javascript
184084 projects - #8 most used programming language

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].