3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('CALCULATION_REGEXP_STRUCTURED_REFERENCE', '([\p{L}_\\\\][\p{L}\p{N}\._]+)?(\[(?>[^\[\]]|(?R))+\])'); $formula = '=SUM(Sales_Data[[#This Row],[Q1]:[Q4]])'; $offset = 5; // This works // No start anchor, but using the preg_match() $offset argument to specify the start point for the search preg_match('/' . CALCULATION_REGEXP_STRUCTURED_REFERENCE . '/misu', $formula, $matches, 0, $offset); var_dump($matches); // This doesn't work // Creating a substring for the part of the formula that we want to search $partialFormula = substr($formula, $offset); var_dump($partialFormula); // and using the start anchor in our regexp preg_match('/^' . CALCULATION_REGEXP_STRUCTURED_REFERENCE . '/misu', $partialFormula, $matches); var_dump($matches);
Output for git.master, git.master_jit
array(3) { [0]=> string(33) "Sales_Data[[#This Row],[Q1]:[Q4]]" [1]=> string(10) "Sales_Data" [2]=> string(23) "[[#This Row],[Q1]:[Q4]]" } string(34) "Sales_Data[[#This Row],[Q1]:[Q4]])" array(0) { }

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:
10.87 ms | 409 KiB | 5 Q