1 |
3a515b92
|
cagy
|
# shebang-regex [![Build Status](https://travis-ci.org/sindresorhus/shebang-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/shebang-regex)
|
2 |
|
|
|
3 |
|
|
> Regular expression for matching a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix))
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
## Install
|
7 |
|
|
|
8 |
|
|
```
|
9 |
|
|
$ npm install --save shebang-regex
|
10 |
|
|
```
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
## Usage
|
14 |
|
|
|
15 |
|
|
```js
|
16 |
|
|
var shebangRegex = require('shebang-regex');
|
17 |
|
|
var str = '#!/usr/bin/env node\nconsole.log("unicorns");';
|
18 |
|
|
|
19 |
|
|
shebangRegex.test(str);
|
20 |
|
|
//=> true
|
21 |
|
|
|
22 |
|
|
shebangRegex.exec(str)[0];
|
23 |
|
|
//=> '#!/usr/bin/env node'
|
24 |
|
|
```
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
## License
|
28 |
|
|
|
29 |
|
|
MIT © [Sindre Sorhus](http://sindresorhus.com)
|