通过php和regex从字符串中删除浮点数

时间:2014-04-17 10:09:35

标签: regex preg-replace

我在PAWN中为SA-MP编写了code, 我用PHP的几个preg_replace调用对这段代码进行了排序,这是半决赛代码。

最后一步是使用preg_replace删除第三个参数(它们是Z坐标),它是float。像这样:

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

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

1 个答案:

答案 0 :(得分:1)

这个正则表达式应该做你想要的:它删除代码中的第三个参数。

$result = preg_replace('/(?m)^([^=]+= GangZoneCreate\(([^,]+,){2})(?2)((?2)[^)]+\);)$/', '\1\3', $subject);