The algorithm is usually this:
1) reverse the name of the package
2) with delimiter '-', fields are:
field 1 is the release
field 2 is the architecture
field 3 is the version
and the rest of the fields is the name
3) reverse the name again
In bash it would be:
Code:
bash-3.1$ echo 'xorg-server-xnest-1.4.0.90-x86_64_slamd64-1' | rev | cut -d - -f 1 | rev
1
bash-3.1$ echo 'xorg-server-xnest-1.4.0.90-x86_64_slamd64-1' | rev | cut -d - -f 2 | rev
x86_64_slamd64
bash-3.1$ echo 'xorg-server-xnest-1.4.0.90-x86_64_slamd64-1' | rev | cut -d - -f 3 | rev
1.4.0.90
bash-3.1$ echo 'xorg-server-xnest-1.4.0.90-x86_64_slamd64-1' | rev | cut -d - -f 1-3 --complement | rev
xorg-server-xnest