package
Regular expression for matching a shebang line
npm install shebang-regexGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
3.2 kB
Includes dependencies.
Regular expression for matching a shebang line
$ npm install shebang-regeximport shebangRegex from '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'