Reputation: 1983
I'm trying to match single line strings that start with ./
, do not contain main
and do end in .js
or .vue
Should match:
./test.js
./component.vue
Should not match:
./main.js
./data.json
I tried using a lookahead like this:
/^\.\/(?!main)(\.js|\.vue)$/
but that doesn't return any of the above strings.
Upvotes: 2
Views: 193
Reputation: 785761
You may use this regex:
^\.\/(?!.*main).*\.(?:js|vue)$
RegEx Breakup:
^
: Start\.\/
: Match ./
at start(?!.*main)
: Negative lookahead to assert we don't have main
anywhere.*\.(?:js|vue)
: Match any string that ends with .js
or .vue
$
: EndUpvotes: 3