jonschlinkert / line-number

Get the line number for each regex match found in a string.

Home Page:https://github.com/jonschlinkert

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

line-number NPM version

Get the line number for each regex match found in a string.

Install

Install with npm:

npm i line-number --save-dev

Usage

var lineNumber = require('line-number');
var fixture = fs.readFileSync('LICENSE-MIT', 'utf8');
var re = /Jon[^,]+/g;
console.log(lineNumber(fixture, re));
//=> results in:
// [
//   {
//     "line": "Copyright (c) 2014 Jon Schlinkert, contributors.",
//     "number": 1,
//     "match": "Jon Schlinkert"
//   }
// ];

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license


This file was generated by verb-cli on July 02, 2014.

About

Get the line number for each regex match found in a string.

https://github.com/jonschlinkert

License:MIT License


Languages

Language:JavaScript 100.0%