3v4l.org

run code in 300+ PHP versions simultaneously
<?php $keywordRegex = '(?<key>-?mock)'; $valueRegex = '"(?<quoted>(?:[^"]|\\\")*)"|(?<unquoted>[^"\s]+)'; $regex = "/(?<=^|\\s){$keywordRegex}:\\s*{$valueRegex}/"; echo $regex, "\n\n"; $inputs = array( 'mock:"foo"', 'mock:""foo', 'mock:""foo""' ); foreach ( $inputs as $term ) { $matches = null; echo $term, "\n"; preg_match( $regex, $term, $matches ); var_dump( $matches ); }
Output for git.master, git.master_jit, rfc.property-hooks
/(?<=^|\s)(?<key>-?mock):\s*"(?<quoted>(?:[^"]|\\")*)"|(?<unquoted>[^"\s]+)/ mock:"foo" array(5) { [0]=> string(10) "mock:"foo"" ["key"]=> string(4) "mock" [1]=> string(4) "mock" ["quoted"]=> string(3) "foo" [2]=> string(3) "foo" } mock:""foo array(5) { [0]=> string(7) "mock:""" ["key"]=> string(4) "mock" [1]=> string(4) "mock" ["quoted"]=> string(0) "" [2]=> string(0) "" } mock:""foo"" array(5) { [0]=> string(7) "mock:""" ["key"]=> string(4) "mock" [1]=> string(4) "mock" ["quoted"]=> string(0) "" [2]=> string(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:
50.9 ms | 402 KiB | 8 Q