3v4l.org

run code in 300+ PHP versions simultaneously
<?php $expression = "5th from end"; preg_match('~^(?:(?P<offset>[0-9]+)(?:st|nd|rd|th)* from )*(?P<position>start|beginning|last|end)+$~i', $expression, $matches); var_dump($matches);

preferences:
37.36 ms | 402 KiB | 5 Q