https://github.com/ragingwind/data-uri-regex
Regexp for data-uri
https://github.com/ragingwind/data-uri-regex
Last synced: about 1 year ago
JSON representation
Regexp for data-uri
- Host: GitHub
- URL: https://github.com/ragingwind/data-uri-regex
- Owner: ragingwind
- License: mit
- Created: 2015-12-16T01:59:43.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-08-16T11:08:10.000Z (almost 6 years ago)
- Last Synced: 2025-04-20T14:18:53.678Z (about 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# data-uri-regex [](https://travis-ci.org/ragingwind/data-uri-regex)
> Regexp for data-uri
## Install
```
$ npm install --save data-uri-regex
```
## Usage
```js
const dataUriRegex = require('data-uri-regex');
var png = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
png.match(dataUriRegex());
//=> true
dataUriRegex().test(png);
//=> true
dataUriRegex().exec(png)[1];
//=> 'data:'
dataUriRegex().exec(png)[2];
//=> 'image/png'
dataUriRegex().exec(png)[3];
//=> 'base64'
dataUriRegex().exec(png)[4];
//=> 'iVB'
```
## API
### dataUriRegex()
It will return the instance of RegExp() for match data-uri strings.
## License
MIT © [ragingwind](http://ragingwind.me)