Interview Prep/Shell Scripting/Variables, quoting and expansions

How do you do search-and-replace, substrings, length and case conversion without external tools?

IntermediateConceptVariables, quoting and expansions
Answer
s="api-prod-api"
echo "${s/api/svc}"     # svc-prod-api   first match
echo "${s//api/svc}"    # svc-prod-svc   all matches
echo "${s/#api/svc}"    # anchored at start
echo "${s/%api/svc}"    # anchored at end
echo "${#s}"            # 12             length
echo "${s:4:4}"         # prod           offset 4, length 4
echo "${s: -3}"         # api            last 3 (space before -)
echo "${s^^}" "${s,,}"  # uppercase / lowercase (Bash 4+)
All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Variables, quoting and expansions