in reply to String matching problem
my $string = "1-2, 3-4, 5-6"; #strip anything but the last digit, $string =~ s/^.*(\d)$/$1/; # string now holds only the last digit, rest should be removed
or
my $last_digit = ''; if ($string =~ /(\d)$/) { $last_digit = $1; }
or
my $last_digit = ''; if ($string =~ /(\d){1}$/) { $last_digit = $1; }
In the last example you may replace {1} if you want any other number of digits from the end of the string
Hope this helps
RL
|
|---|