Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^(?<exe>npm)?\ ?(?<run>(?<=\k<exe> )run(?:-script)?)?\ ?(?<command>(?<=\k<run> )[a-z]+(?:[-|:|.|_][a-z]+)?|(?<!\k<run> )[a-z]+(?:[-][a-z]+)?)?\ ?(?<pkgdetails>[a-z0-9\>\=\:\+\#\^\.\@\/][a-z0-9\>\=\:\+\#\^\~\.\@\/\-]+)?\ ?(?<options>(?:\ [-]{1,2}[a-zA-Z]+(?:[-][a-z]+)*)*)?$
/
gm

Description

This is a npm expression parser that can be used, for instance, to create shims.

This RegEx has been created for spypkg module.

Submitted by marckassay - 6 years ago