The main problem is not the regular expression, but the fact that the sed command uses single quotes for its commands ('s/.../.../'
). You can replace the single quotes with double quotes to get rid of that problem ("s/.../.../"
). You also need to escape the square brackets in the search part.
sed -i "s/\$normal\[''\];/\$normal['localhost'];/" file
Hope this helps.