in reply to Re^2: Sorting array
in thread Sorting array
On closer inspection, this doesn't seem to be quite a complete solution. The below section of the approach I think is expected to return the replaced value, in this case 'ID'.
It instead returns a 1 if a replacement is made or an empty string if it is not. It happens to produce the correct sort in this case because of the narrow data set used.
my $string = 'ID13'; say scalar( $string =~ s/\d+// );
Does anyone else know of a way to return the correct match in place of this line? The below is a very poor solution I expect.
my $string = 'ID13'; say join('', grep( /[A-Za-z]/, split('',$string) ) );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Sorting array
by Anonymous Monk on Sep 24, 2011 at 17:12 UTC |