I'm trying to analyze a bunch of C# files I have, with grep, to match a particular type of for-loop. Specifically, anything that looks like the following would match:
for (int i = 0; i < foo.Length; i++)
{
foo[i] = bar[i];
}
I tried installing pcregrep after I learned grep didn't support multiline, but it's not working out. Here is my (admittedly very sloppy) regexp:
pcregrep -rlM "for (int i = 0; i < [A-Za-z]*\.Length; i++)\n[ *]\{\n[ *][A-Za-z]*\[i\] = [A-Za-z]*\[i\];\n[ *]\}"
I ran this command about 10 minutes ago, and it's still running (albeit at very low CPU usage, surprisingly). Am I doing something wrong / Is there a faster way to do this?