Reputation: 466
Hi everyone just a quick question about visual studio.
I have alot of pixel calls in a program. I know this is probably very inefficient but I am just messing around with it. approx 90,000 calls.
example of calls:
gfx.PutPixel( 449 + x,339 + y,0,0,0 );
The silly thing is here i really don't need these at all. I only want the pixels with a rgb values(these have none, the last 3 parameters are r,g,b). I was wondering if there is an expression I can type into find and replace to get rid of them all together as it would reduce the amount of calls by waayyy over half.
This is not something that can be done manually as around half are 0 value and the other half are coloured pixels.
If i could use a regular expression or something to account for the 499 + x, 399 + y part of the function call then I could delete all the unwanted lines but I have no idea what to type.
Thanks in advance, Paul
Upvotes: 0
Views: 179
Reputation: 16940
You can use this regex:
\s*gfx\.PutPixel\(.*?(?:,\s*0\s*){3}\);\s*
Should match what you want.
Here's the part of regex that matters for you: \(.*?(?:,\s*0\s*){3}\)
It starts with non-greedy match for anything and is expected to end with 3 zeros separated with commas (with optional space around these zeros). It won't match non-zeros.
Upvotes: 1