finding string at runtime

Hi

I am creating a script in shell (sh), in which i will enter a string at runtime. let i will enter the string asdfergtdev_DEV2(or DEV,DEV3,DEV1 etc). i want it will find DEV2(it will be only find DEV2 at last 4 digit 3 in case only DEV,no metter if before it, there is dev) and append _qqq01 at end like sdfergtdev_DEV2_qqq01. if there is not DEV at the end it will append _aa01
for exp :- sdfergtdev123a_RC01.

Please help !
Thanks,
Inder

Decoding your requirement isn't straightforward. Do you have code which almost works? Could you post it and tell us what's wrong with it?