An alternative to Brian Roachs would be to respond to such a capture group
$string =~ /^\D*\d\D*\d\D*(\d)/; print $1;
means match the beginning of a line with 0 or more digits ( \D ), then the digit ( \D ), the same thing, and then the digit you want to have in brackets, so it will be saved in $1 .
But you need a longer regex, so I would prefer its solution (+1).
source share