Bash string substition

How to replace a substring, given a string in Bash.

Replacing single instance of substring

input="1-100x100.jpg"
echo ${input/.jpg/.webp} # 1-100x100.webp
input="yt-dlp.exe"
echo ${input/.exe/} # yt-dlp
input="1-100x100.jpg.jpg"
echo ${input/.jpg/.webp} # 1-100x100.webp.jpg

Replacing every instances of substring

input="2038-01-01"
echo ${input//-/_} # 2038_01_01
input="2038-01-01T00:00:00Z"
echo ${input//[\-T:Z]/} # 20380101000000

Reference