3v4l.org

run code in 500+ PHP versions simultaneously
<?php $keywords = ["key1", "key2"]; $escaped = implode('|', array_map('preg_quote', $keywords)); $pattern = "/\b(?:" . $escaped . ")\b" . ":?(?:\h+|$)|\b(?!(?:" . $escaped . ")\b)[^\s:]+:/"; $strings = [ "aaa bbb key1 ccc", "aaa bbb key1:xxx key2:", "aaa bbb key1: xxx ccc", "aaa bbb key1 :xxx ccc", "aaa bbb xxx:yyy zzz", "aaa bbb ccc", "aaa bbb key1:aaa ccc ddd", "aaa bbb key2:aaa key1:bbb", "aaa bbb aakey1", "aaa bbb key1aa", "aaa bbb key1aa" ]; foreach ($strings as $s) { preg_match_all($pattern, $s, $matches); if (count($matches[0]) > 0) { foreach ($matches[0] as $m) { echo "Invalid string -->'$m' is invalid format, please check it again..." . PHP_EOL; } } else { echo "Valid string --> '$s'" . PHP_EOL; } }
Output for git.master, git.master_jit, rfc.property-hooks
Invalid string -->'key1 ' is invalid format, please check it again... Invalid string -->'key2:' is invalid format, please check it again... Invalid string -->'key1: ' is invalid format, please check it again... Invalid string -->'key1 ' is invalid format, please check it again... Invalid string -->'xxx:' is invalid format, please check it again... Valid string --> 'aaa bbb ccc' Valid string --> 'aaa bbb key1:aaa ccc ddd' Valid string --> 'aaa bbb key2:aaa key1:bbb' Valid string --> 'aaa bbb aakey1' Valid string --> 'aaa bbb key1aa' Valid string --> 'aaa bbb key1aa'

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:
53.66 ms | 1360 KiB | 4 Q