I’m trying to search my codebase for instances of the following pattern:
m_vParts[foo] =
And similar instances with varying whitespace. So I can up with this regex:
m_vParts\[.*\]\s*=[^=]\s*
When I test this at http://gskinner.com/RegExr/ and other regex-tester type sites, it finds exactly what I want. However, when I actually grep (or egrep) I get no results. My guess is my regex isn’t well-formed for grep‘s dialect of regexes, but I’m not sure exactly where I’m off.
Here is the actual command I give:
[e]grep -Irn "m_vParts\[.*\]\s*=[^=]\s*" .
I’ve tried with both single and double quotes.
Here’s a small sample of code that is exemplary of the codebase:
pcTab->m_vParts[iLastPart] = pcPart;
if ( m_pcCurrentTab->m_vParts[i]== pcPart )
I would expect that the first line would be a match, and the second line would not.
Also, I should note that I’m using GnuWin32 grep on Windows 7 x64.
Thanks in advance for any guidance here; very much trying to avoid the non-automated search 🙂
Just add quotes around the re:
As you can see, all works.