Test, validate and match regular expressions
Parses npm command-line expressions into named parts: the 'npm' executable, an optional 'run'/'run-script' keyword, the command name, package details with version specifiers (e.g. package@^1.2.3, ~, >=, #), and CLI flags like -g or --save-dev. It uses JavaScript named capture groups with lookbehind backreferences (\k<...>) to enforce that command and package segments appear in structurally valid positions. Useful for validating and tokenizing npm commands in build tooling, linters, or dev CLI parsers.