3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = '/^[^\d\r\n]*\b(\d+)([admno]\d+)?/'; $strings = [ "Some string 12345a1% some other string.", "Somet string 23456b2! some other string" ]; foreach ($strings as $s) { preg_match($pattern, $s, $match); var_dump($match); }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array(3) { [0]=> string(19) "Some string 12345a1" [1]=> string(5) "12345" [2]=> string(2) "a1" } array(2) { [0]=> string(18) "Somet string 23456" [1]=> string(5) "23456" }

preferences:
92.64 ms | 1267 KiB | 4 Q