I'm not allowed to comment, but the accepted solution cites an example that seems broken. Line 18 should be:
s,[/\.*[],\\&,g
Not
s,[/\[.*],\\&,g
The latter will complain with modern sed (or 'gsed' if you're in *BSD) about an unterminated expression on line 18.