Help for this page

Select Code to Download


  1. or download this
    my $s = 'abc123+';
    $s =~ s/[^0-9+]//g;
    
  2. or download this
    $s =~ s/[^0-9]+//g;
    
  3. or download this
    $s = 'abc123+';
    # remove any non-digit
    $s =~ tr/0-9//cd;
    # or remove any non-alphanumeric
    $s =~ tr/A-Za-z0-9//cd;