Regular expressions for matching node.js require statements.
Install with npm
npm i requires-regex --save
npm test
var re = require('requires-regex');
re().exec('var isDir = require(\'is-directory\');');
//=>
// [ 'var isDir = require(\'is-directory\')',
// 'var isDir = ',
// 'isDir',
// 'is-directory',
// index: 0,
// input: 'var isDir = require(\'is-directory\');' ]
'var path = require(\'path\');\nvar list = require(\'dirs\');'.match(re());
//=> [ 'var path = require(\'path\')', 'var list = require(\'dirs\')' ]
re().test('require(\'foo\');');
//=> true
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on September 20, 2014.