Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
(?<=--path[ |=])dist\/.*(?=$)
/
gm

Description

Ideally, to be used with JS Array join and String replace methods, like so:

process.argv.join(' ').replace(/["']/g, '').match(/(?<=--path[ |=])dist\/.*(?=$)/);

The join is to convert array to string to prevent iterating. The replace is to remove single or double quotes for easier matching. The 'dist' folder is a safeguard to prevent matching anything outside of that folder.

Submitted by Marc Kassay - 3 years ago