3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 */
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
123456TX 12345TX 45232GB