【发布时间】:2022-01-12 17:43:27
【问题描述】:
我正在使用 pre-commit 来运行一些钩子,并且我有一个正则表达式,其中只包含我希望在其上运行钩子的文件(目录)列表。问题是我的正则表达式匹配精确的字符串 + 任何其他附加字符串到第一个字符串。
hooks:
- id: xdoc
files: (?=(analytic|authentication|store))
exclude: (?=(apps|serializers|admin|test|migrations|__init__.py))
stages: [commit]
这里我最初有两个以字符串 store 开头的应用程序:
store
storespecifics
上面的正则表达式匹配两者,我只是想精确匹配store。
例如,我尝试了(?=^(analytic|authentication|store)$),但没有匹配到。
【问题讨论】:
标签: python regex python-re pre-commit-hook pre-commit.com