1

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?

Joseph
  • 80
  • 14

1 Answers1

1

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

Roman Nakutnyi
  • 791
  • 7
  • 11