Filip
Filip

Reputation: 346

Regex to skip all folders except one

I have the following entry to a file that ignores certain files and directories when I deploy my app:

skip_files:
- ^default/node_modules$
- ^cron$
- ^default/static/app$
- ^\.git$
- ^default/(.*/)?#.*#$
- ^default/(.*/)?.*~$
- ^default/(.*/)?.*\.py[co]$
- ^vendor/(.*/)?.*\.dat$
- ^keys/!privateKeys.json$
- ^default/(.*/)?.*/RCS/.*$
- ^default/(.*/)?\..*$

Also I have the following directories:

vendor/google/apiclient-services/src/Google/Service/Acceleratedmobilepageurl vendor/google/apiclient-services/src/Google/Service/AdExchangeBuyer

vendor/google/apiclient-services/src/Google/Service/AdSense

I want to have a single rule in the skip files section that ignores the first two ones, but still deployes the Adsense folder.

The reason for this is that Google/Service/* includes a lot of folders but actually I need only two of them to be uploaded. It would make more sense to have a single rule instead of 100 individual ignore rules.

Upvotes: 0

Views: 749

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

You have to use negative lookahead.

^Google/Service/(?!AdExchangeBuyer\b|AdSense\b)

DEMO

Upvotes: 1

Related Questions