$re = '/_(1[6-9]|2[0-4])$/m';
$str = 'x2016_17_7
x2017_188
x2018_199
x2019_20_10
x2020_21_11
x2021_22_12
x2022_23_13
x2023_20_10
x202025_15
x2016_17_16
x2017_18_17
x2018_19_18
x2019_20_19
x2020_21_20
x2021_22_21
x2022_23_22
x2023_20_23
x2020_25_20';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php