regextract

1.0.0 • Public • Published

regextract

Extracting text with Regular Expression

npm Build Status

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

Readme

Keywords

none

Package Sidebar

Install

npm i regextract

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.91 kB

Total Files

5

Last publish

Collaborators

  • ajhsu