3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '987ABC11-15; 77; 877; 66-68'; $pattern = '~(^\d+[A-Z]+)?\d+\D+\K~'; echo preg_replace_callback($pattern, function($m)use(&$prefix) { // var_export($m); // if you want to see if (isset($m[1])) $prefix = $m[1]; return $prefix; }, $string, -1, $count); echo "\nmickmackusa count = $count"; echo "\n---\n"; echo preg_replace_callback('/^(\d+[A-Z]+)|\d+/', function($m) use (&$pfx) { // more replacements, easier to comprehend if (!empty($m[1])) $pfx = $m[1]; else return $pfx . $m[0]; }, $string, -1, $count); echo "\nbobblebubble count = $count";
Output for git.master_jit, git.master, rfc.property-hooks
987ABC11-987ABC15; 987ABC77; 987ABC877; 987ABC66-987ABC68 mickmackusa count = 5 --- 987ABC11-987ABC15; 987ABC77; 987ABC877; 987ABC66-987ABC68 bobblebubble count = 7

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
25.45 ms | 405 KiB | 5 Q