Surviving sed When Replacing Slashes

Usually, searching and replacing using sed looks something like this:

sed -e ‘s/abc/yyy/g’ file.txt

Now, how would we for example modify a string of the form:

http://example.com/directory/index.html

to become

http::example.com::directory::index.html

We can use something like this:

sed -e ‘s/:\/\//::/g;s/\//::/g’ file.txt

But who said that we have to use a slash as a separator when our regular expression is full of slashes?
The following is equivalent but much cleaner:

sed -e ‘s#://#::#g;s#/#::#g’ file.txt

You can use any character as a separator.

Enjoy.