3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'xxABC1xxxABC2xx'; if ( preg_match('/\d[A-Z]+x/', strrev($str), $match) ) echo strrev($match[0]);

preferences:
27.62 ms | 402 KiB | 5 Q