use strict; use warnings; my $string = "/qwjhj/sdvbb/vuvs/tryt3687fbhvh/vv1vh/382411"; my ($number) = $string =~ /(\d+)$/; print $number; #### 382411 #### my ($number) = $string =~ /(\d+)$/; ^ ^ ^^ | | || | | |+ - End of the string | | + - End capture | + - One or more digits + - Begin capture