Using sed will work, and is probably pretty portable to different shells. However, it is not never efficient, so if you are doing the operation many times, the time taken can quickly add up.
Using parameter expansion modifiers is much
quicker. See the Parameter Expansion
section of the bash manual page for a list of possible expansions which work in bash. A few of these are bash-specific. If you use a different shell, check the relevant part of the manual page for your shell.