简体   繁体   中英

Git Grep Multiple line Regex

I wrote a regex to find any file containing space Word [ and here is the regex.

^\s+Session\[

and I want to use this regex in git grep, so I set up a file in my repo that matched the regex and runs it.

here is what I run

git grep '^\s+Word\[' -- '*.cs'


but it returns nothing. I'm really new to git and regex any reference or suggestion to solve this problem?

It looks like you are trying to use Perl regular expressions syntax with git grep . Just add -P (perl-regexp) option and it will work.

UPD: for those who comes here to find about multi line patterns to git grep (just like me): Git Grep Multiple Words on Multiple Lines

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM