An open API service indexing awesome lists of open source software.

https://github.com/jonschlinkert/line-number

Get the line number for each regex match found in a string.
https://github.com/jonschlinkert/line-number

index javascript jonschlinkert line match matches number regex regex-match regular-expression split string util

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

        

# line-number [![NPM version](https://badge.fury.io/js/line-number.png)](http://badge.fury.io/js/line-number)

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

## Install
Install with [npm](npmjs.org):

```bash
npm i line-number --save-dev
```

## Usage

```js
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**

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

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

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 02, 2014._