3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regex = '/X(*MARK:A)Y|X(*MARK:B)Z/'; preg_match($regex, "XY", $matches); echo $matches['MARK'], "\n"; // A preg_match($regex, "XZ", $matches); echo $matches['MARK'], "\n"; // B preg_match($regex, "XP", $matches); echo $matches['MARK'], "\n"; // Should also be B, instead: Notice: Undefined index: MARK

preferences:
68.2 ms | 402 KiB | 5 Q