npm Package Name
intermediateMatches valid npm package names including scoped packages.
npmpackagenodedevelopment
Pattern
/(?:@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*/gTry It
0 of 7 strings matched
Explanation
Matches npm package names: optional scope (@org/) followed by a lowercase name. Names can contain lowercase letters, digits, hyphens, dots, underscores, and tildes.
Test Strings
Matching
- react
- @types/node
- lodash
- @my-org/my-package
Non-matching
- !!!
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);