I'm a little new to regex and I can't figure out how to set up a regex for this pattern I'm trying to do.
The expression is intended to prefix the Python script, and it will trigger the pre-commit hook if the files that commit match it.
My list of sample files
vars/prod-region1/mysql.yml
vars/prod-region1/keys.yml
vars/prod-region1/test.yml
vars/stage-region2/mysql.yml
vars/stage-region2/keys.yml
vars/stage-region2/test.yml
vars/local/mysql.yml
vars/local/test.yml
I need a regex pattern that will match the files that fall into the following directory pattern
- vary / prod * / mysql.yml
- vary / prod * / keys.yml
- vary / step * / mysql.yml
- vary / step * / keys.yml
My current effort
vars/(prod*|stage*)/(mysql|keys).yml
which is a serious mistake. Any help would be great.
source
share