Help for this page

Select Code to Download


  1. or download this
    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
    
  2. or download this
    my $last_digit = '';
    if ($string =~ /(\d)$/) {
        $last_digit = $1;
    }
    
  3. or download this
    my $last_digit = '';
    if ($string =~ /(\d){1}$/) {
        $last_digit = $1;
    }