Question

I have a code written in PAWN for SA-MP, I sorted this code by several preg_replace calls with PHP and this is the semi-final code.

Final step is to remove the third parameter (They're Z-coordinates) with preg_replace which is float. like this:

SILLY4 = GangZoneCreate(-2178.69, -599.884, -0.00012207, -1794.92, -324.114);

to

SILLY4 = GangZoneCreate(-2178.69, -599.884, -1794.92, -324.114);
Was it helpful?

Solution

This regex should do what you want: it removes the third parameter in the code.

$result = preg_replace('/(?m)^([^=]+= GangZoneCreate\(([^,]+,){2})(?2)((?2)[^)]+\);)$/', '\1\3', $subject);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top