【发布时间】:2011-03-14 14:15:22
【问题描述】:
我需要将“{Z}”替换为“test(Z)”,其中 Z 始终是使用 PHP 和正则表达式的无符号整数(除非有更快的方法?)。
$code='{45} == {2}->val() - {5}->val()';
// apply regex to $code
echo $code;
// writes: test(45) == test(2)->val() - test(5)->val()
棘手的部分是它需要以关于速度和内存使用的最佳方式完成。
【问题讨论】:
标签: php regex performance