Ok, so a variable num of 'fields' before the 4.999 etc.
IF the 4.99 is a constant ie where you want to grab the prefix
echo xx-yyyy-zzzz-4.999.9-0.3.beta.20021007git.8.amzn1.x86_64|sed -e s/-4.*//
echo xx-yyyy-4.999.9-0.3.beta.20021007git.8.amzn1.x86_64|sed -e s/-4.*//
You need to delineate the rules exactly; what can change, what can vary and which part you want extracted.
Edit: so had that open while you posted above. Here's the amended sed
sed -e s/-[0-9].*//
Basically remove pattern that starts with '-', followed by a digit, followed by anything...