You could use a regular expression with perl
Code:
s/^.+-(\d+\.?\d+\.?\d+)-?\d*/\1/;
I see this as:
^.+- : match one or more caracter until the dash (included)
(\d+\.?\d+\.?\d+): match one digit or more followed by a dot or not, etc...
-? : match one dash or not
\d* : match zero or more digit
[edit]
Note that it will remove the "-12" from "1.0.3-12", it is what you want if I understand correctly, no?
You use it like:
Code:
my $str;
$str = "recommended : bzip2-program-1.0.3-12";
$str =~ s/^.+-(\d+\.?\d+\.?\d+)-?\d*/\1/;
print $str . "\n";
$str = "recommended : bzip2-program-1.0.3";
$str =~ s/^.+-(\d+\.?\d+\.?\d+)-?\d*/\1/;
print $str . "\n";