extracting data from a string

Hi there, I have a bunch of vlan tagged network interfaces that are named as follows

e1000g111000
e1000g99001
e1000g3456000
nge2002

where the 'e1000g' and 'nge' parts of the name are the driver, the red and blue bits above define the VLAN and the last digit on the end defines the interface number/instance

I am trying to figure out a way of writing a script that will basically say ...

if you find an interface called e1000g111001 then the physical interface is called e1000g1

or

if you find an interface called nge7002 then the physical interface is called nge2

Is there an easy way of me making this determination of what physical interface any given vlan tagged interface is using?

the trouble is that the red bit (the vlan number) can really be any length but the blue bit will generally always be '00'

Is there an easy way to extract just the physical interface name regardless of what 'red and blue' bits are in the middle?

any help on this would be greatly appreciated

Try:

perl -pe 's/[0-9]+([0-9])$/\1/' file
if=e1000g111000
a=${if##*[a-z]}
b=${if%"$a"}
c=${if%?}
d=${if#"$c"}
echo "$b$d"

thanks guys, i particularly like that bit of perl,

cheers