Reputation: 207
i need to create a regex expression that match all **.ts (typescripts files) but doesn't allow karma and jasmine test files: **.spec.ts and **.e2e.ts
Any help would be appreciated. :)
Upvotes: 1
Views: 1924
Reputation: 626738
You may use
^(?!.*\.(e2e|spec)\.ts$).*\.ts$
Details:
^
- start of string(?!.*\.(e2e|spec)\.ts$)
- the string cannot end with .e2e.ts
nor with .spec.ts
(this is a negative lookahead that fails the match if its pattern matches: any 0+ chars as many as possible (.*
) up to the last .
(\.
), e2e
or spec
((e2e|spec)
), again a .
and then ts
at the end of the string ($
)).*
- any 0+ chars as many as possible up to the last\.ts
- .ts
literal char sequence$
- end of string.Upvotes: 1