{"id":15679765,"url":"https://github.com/jonschlinkert/requires-regex","last_synced_at":"2025-05-07T09:42:55.806Z","repository":{"id":20968337,"uuid":"24257176","full_name":"jonschlinkert/requires-regex","owner":"jonschlinkert","description":"Regular expressions for matching node.js require statements.","archived":false,"fork":false,"pushed_at":"2018-04-15T17:58:03.000Z","size":28,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T06:47:48.245Z","etag":null,"topics":["javascript","nodejs","regex","regexp","regular-expression","require","requires"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-20T07:52:30.000Z","updated_at":"2023-11-10T01:23:09.000Z","dependencies_parsed_at":"2022-07-13T06:40:31.870Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/requires-regex","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Frequires-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Frequires-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Frequires-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Frequires-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/requires-regex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252852587,"owners_count":21814384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","regex","regexp","regular-expression","require","requires"],"created_at":"2024-10-03T16:35:45.046Z","updated_at":"2025-05-07T09:42:55.761Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","readme":"# requires-regex [![NPM version](https://img.shields.io/npm/v/requires-regex.svg?style=flat)](https://www.npmjs.com/package/requires-regex) [![NPM monthly downloads](https://img.shields.io/npm/dm/requires-regex.svg?style=flat)](https://npmjs.org/package/requires-regex) [![NPM total downloads](https://img.shields.io/npm/dt/requires-regex.svg?style=flat)](https://npmjs.org/package/requires-regex) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/requires-regex.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/requires-regex)\n\n\u003e Regular expression for matching javascript require statements.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save requires-regex\n```\n\n## Usage\n\nTHe main export is a function that must be called. This ensures that a new regex is returned each time the function is called.\n\n```js\nconst regex = require('requires-regex')();\nconst match = regex.exec('const foo = require(\\'@bar/baz\\');');\n\nconsole.log(match);\n// [ 'const foo = require(\\'@bar/baz\\');',\n//   undefined,\n//   'foo',\n//   '\\'',\n//   '@bar/baz',\n//   'bar',\n//   'baz',\n//   index: 0,\n//   input: 'const foo = require(\\'@bar/baz\\');' ]\n```\n\n**Match results**\n\n* `0` - the full match\n* `1` - require statements inside quoted strings, otherwise undefined.\n* `2` - variable name before `require()`, if defined, otherwise undefined\n* `3` - leading quote inside `require()`, this is used as a reference to match ends on a trailing quote of the same type\n* `4` - the full name inside the `require()` statement. For example, in `require(\"@foo/bar\")`, the full name is `@foo/bar`.\n* `5` - the first segment of a scoped name. For example, `foo` in `@foo/bar`. Otherwise undefined.\n* `6` - the second segment of a scoped name. For example, `bar` in `@foo/bar`. Otherwise undefined.\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [lint-deps](https://www.npmjs.com/package/lint-deps): CLI tool that tells you when dependencies are missing from package.json and offers you a… [more](https://github.com/jonschlinkert/lint-deps) | [homepage](https://github.com/jonschlinkert/lint-deps \"CLI tool that tells you when dependencies are missing from package.json and offers you a choice to install them. Also tells you when dependencies are listed in package.json but are not being used anywhere in your project. Node.js command line tool and API\")\n* [match-requires](https://www.npmjs.com/package/match-requires): Match require statements in a string. Returns an array of matching require statements. Each match… [more](https://github.com/jonschlinkert/match-requires) | [homepage](https://github.com/jonschlinkert/match-requires \"Match require statements in a string. Returns an array of matching require statements. Each match is an object with line number, variable name, and module name. Statements in code comments are ignored.\")\n* [regex-cache](https://www.npmjs.com/package/regex-cache): Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of… [more](https://github.com/jonschlinkert/regex-cache) | [homepage](https://github.com/jonschlinkert/regex-cache \"Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of the same string and options, resulting in surprising performance improvements.\")\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 22 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 1 | [alvinsight](https://github.com/alvinsight) |\n\n### Author\n\n**Jon Schlinkert**\n\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 15, 2018._","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Frequires-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Frequires-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Frequires-regex/lists"}