regextract
v1.0.0
Published
Extracting text with Regular Expression
Downloads
5
Readme
regextract
Extracting text with Regular Expression
Install
npm install regextract --save
API
var result = extract(text, RegExp);
result.matches
Type: Array
Matches of RegExp patterns to the source text.
result.extracts
Type: Array
Captured groups of capturing parentheses within RegExp patterns to the source text.
result.captured
Type: Array
Alias to result.extracts
.
Usage
Require package
var extract = require('regextract');
Find matches
extract('iPhone6, iPhone7, iPhone8, iPhoneX', /iPhone\d/g);
// You'll get:
{
matches: ['iPhone6', 'iPhone7', 'iPhone8'],
extracts: []
}
Get extracted texts
extract('Price: NTD$299', /NTD\$(\d+)/g)
// You'll get:
{
matches: ['NTD$299'],
extracts: ['299']
}
License
MIT