3v4l.org

run code in 300+ PHP versions simultaneously
<?php if ( ! defined('PHP_EOL')) { define('PHP_EOL', "\n"); } function normalise($string) { preg_match('~[0-9]+[a-z]+$~i', $string, $match); if ( ! isset($match[0])) { return false; } return strtoupper($match[0]); } $tests = array( 'Deu123456tx', 'Deu-12345tx', '12de45232gb', ); foreach ($tests as $test) { echo normalise($test), PHP_EOL; } /* 123456TX 12345TX 45232GB */

preferences:
45.02 ms | 402 KiB | 5 Q