Skip to content
Regular expression for matching a shebang line
JavaScript TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Tidelift tasks Sep 10, 2019
.editorconfig
.gitattributes Require Node.js 8, add TypeScript definition (#6) Apr 27, 2019
.gitignore Require Node.js 8, add TypeScript definition (#6) Apr 27, 2019
.npmrc Require Node.js 8, add TypeScript definition (#6) Apr 27, 2019
.travis.yml
index.d.ts Meta tweaks Apr 27, 2019
index.js
index.test-d.ts Require Node.js 8, add TypeScript definition (#6) Apr 27, 2019
license
package.json
readme.md Tidelift tasks Sep 10, 2019
test.js Require Node.js 8, add TypeScript definition (#6) Apr 27, 2019

readme.md

shebang-regex Build Status

Regular expression for matching a shebang line

Install

$ npm install shebang-regex

Usage

const shebangRegex = require('shebang-regex');

const string = '#!/usr/bin/env node\nconsole.log("unicorns");';

shebangRegex.test(string);
//=> true

shebangRegex.exec(string)[0];
//=> '#!/usr/bin/env node'

shebangRegex.exec(string)[1];
//=> '/usr/bin/env node'

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
You can’t perform that action at this time.