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?

Upvotes: 1

Views: 739

Answers (1)

Roman Nakutnyi
Roman Nakutnyi

Reputation: 1006

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

Upvotes: 1

Related Questions