Regex template for mapping directories to a prefix

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.

+4
source share
1

*. , ; ( ). , , - . , , .* , . \S* . d* d . e*.

-, . , , \S*. /. ., , ..:

vars\/(prod\S*|stage\S*)\/(mysql|keys)\.yml

.

+4

Source: https://habr.com/ru/post/1615152/


All Articles