# Preferred Alternative
We could simply modify the rpm query to only output the name.
rpm -qa --queryformat "%{NAME}\
"
**Or we can get dirty with a regex**
Not exactly "straight forward" but here is a sed regex that should be able to do it.
sed -e 's/\([^\.]*\).*/\1/;s/-[0-9]*$//' <<< "perl-Text-ParseWords-3.30-1.fc22.i686"
This should handle everything except for in there is a period in the package name (I don't even think that is allowed).
**Quick breakdown**
* `s/\([^\.]*\).*/\1/` grab everything before the first period. So `perl-Text-ParseWords-3.30-1.fc22.i686` becomes `perl-Text-ParseWords-3`
* `s/-[0-9]*$//`get rid of that trailing `-` and first version digit. So `perl-Text-ParseWords-3` becomes `perl-Text-ParseWords`.