Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
regex for files of a particular file extension that exclude one particular word

I want to exclude file paths that have capsize anywhere in the path in node or javascript but I am failing to get the syntax right.

const re = /.*((?!capsize).*)\.css\.ts/;

console.log(re.test('src/packages/graph.css.ts')) // should be true

console.log(re.test('packages/vanilla-extract/capsize.css.ts')) // should be false

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

First you need to specify, that you want to match whole string, ie. add start and end mark. (Otherwise it will skip .* as no symbol were matched, which is ok from regex point of view)

Second you need to put not follow by right after any symbol (ie. saying, there can be 0 to infinity symbols not followed by capsize).

const re = /^(.(?!capsize))*\.css\.ts$/;

console.log(re.test('src/packages/graph.css.ts')) // should be true

console.log(re.test('packages/vanilla-extract/capsize.css.ts')) // should be false

about 4 years ago · Juan Pablo Isaza Report

0

One possible way:

const re = /^(?!.*?capsize).*\.css\.ts$/;

console.log(re.test('src/packages/graph.css.ts')) // should be true

console.log(re.test('packages/vanilla-extract/capsize.css.ts'))

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!