3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'jème lé ponés'; mb_ereg_search_init($string, '(?<=[ ^])\w+'); // Detect words while ($pos = mb_ereg_search_pos()) { $match = mb_ereg_search_getregs()[0]; $matchBasedOnPos = substr($string, $pos[0], $pos[1]); if ($matchBasedOnPos !== $match) { throw new \LogicException("Match based on position '{$matchBasedOnPos}' does not correspond to actual match '{$match}'"); } var_dump(mb_strlen($matchBasedOnPos)); }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.30, 8.0.0 - 8.0.23, 8.1.0 - 8.1.10
int(2) int(5)

preferences:
57.55 ms | 409 KiB | 5 Q