I’m trying to capture the last digits in this line in a regex group:
The input:
9 Power_On_Hours 0x0032 099 099 000 Old_age Always - 54654
My pattern:
/Power_On_Hours.+Always\s.+([0-9]{1,5})/
I just can’t seem to get it to capture “54654”, it’s returning undef 🙁
Actually, that capture group should grab ‘4’, not undef. Your final
.+will eat up everything until the last digit and then capture that to$1. This revision captures all the digits to$1:The
?makes the.+non-greedy, so it will match characters up to when the digits (\d) start to match.