regex - git bash中的正则表达式要转义哪些字符
问题描述
正则表达式:
(壮举|修复|hf)/\d*/.*
适用于以下文本:
Merge pull request #32 in TAS/tashtit from feat/140844/fix-sonar-properties to develop feat/140844/ fixing problems found by sonar Merge pull request #31 in TAS/tashtit from feat/140844/fix-sonar-properties to develop feat/140844/ fix sonar properties and git ignore Merge pull request #30 in TAS/tashtit from feat/141316/jndi-junits to develop Merge pull request #28 in TAS/tashtit from feat/142391/log-event-fix to develop feat/142391/ fix jenkins Merge branch 'develop' into feat/141316/jndi-junits Merge pull request #27 in TAS/tashtit from feat/142391/log-event-fix to develop feat/142391/ Merge branch 'develop' of http://pa2vmp56.blmain.prod:7990/scm/tas/tashtit into feat/142391/log-event-fix feat/142391/ fix jenkins Merge branch 'feat/141466/Check-that-refactored-code-works-with-J2EE' into feat/141316/jndi-junits Merge pull request #26 in TAS/tashtit from feat/141466/Check-that-refactored-code-works-with-J2EE to develop feat/141466/ Merge branch 'develop' of ssh://pa2vmp56.blmain.prod:7999/tas/tashtit into feat/141466/Check-that-refactored-code-works-with-J2EE feat/141466/ fixing events Merge pull request #25 in TAS/tashtit from feat/141466/Check-that-refactored-code-works-with-J2EE to develop feat/141466/ fixing application port Merge branch 'develop' into feat/141316/jndi-junits Merge branch 'develop' into feat/141316/jndi-junits Merge branch 'develop' into feat/141316/jndi-junits
问题是在 git bash 中编写命令时,我收到有关转义的错误。这是命令:
git -C /c/workspace/Tashtit-Spring-Dev-Build log tashtit.spring_build_1902.01.1911211325..tashtit.spring_build_1902.01.1911281247 --grep=(?:feat|fix|hf)\/\d*\/.* --all-match --pretty=%s > /c/workspace/Tashtit-Spring-Dev-Build/log.log
因此,我尝试转义特殊字符,如下所示:
git -C /c/workspace/Tashtit-Spring-Dev-Build log tashtit.spring_build_1902.01.1911211325..tashtit.spring_build_1902.01.1911281247 --grep='\(?:feat|fix|hf\)\/\d*\/.*' --all-match --pretty=%s > /c/workspace/Tashtit-Spring-Dev-Build/log.log
结果是空的,我错过了什么?
解决方案
推荐阅读
- c# - 如何将 void 指针 (C++) 复制到 byte[] (C#) (CLI)
- multithreading - Kotlin 最多运行一个任务
- vue.js - 使用 v-validate 字段绑定验证动态字段
- javascript - 如何在传单中为 openweathermap 图层添加字幕?
- tensorflow - 迁移学习——如何让历史连续
- google-cloud-platform - Kubernetes:负载均衡器与就绪健康检查
- google-analytics - Workbox Analytics 可以将多少调用保存到磁盘?
- c - 如何将此while循环转换为for循环?
- python - 使用 Matplotlib 的动画 - 无法运行循环
- python - 创建新列时不再支持时间戳错误