Check into the "expr" command for regular expression stuff from ksh.