Here's another good source for string manipulation
information in bash. There's lots of good stuff you can do right inside the shell, once you have them stored in variables.
Another hint: instead of regular variables, have a look at arrays.
Of course if one of your requirements is that the script be portable (posix compliant), then you'll be much more limited in the techniques you can use. See here for some ideas on how to convert bash features to posix.