I have a string of expressions that should not be split across lines, so I have placed non-breaking spaces between them. However, they spill over into the margin. How do I fix this? Here is my MWE:
\documentclass{book}
\usepackage{lipsum}
\begin{document}
This text shows that non-breaking spaces are not working properly: ``a:a~b:b~c:d~e:e~f:f~g:h''. \lipsum
\end{document}
If the expression is too long, I want it to be moved to start the next line. I have tried placing \allowbreak before the expression, but it does not change the result.

~never breaks, as far as I know, even with\allowbreak– Jul 24 '15 at 09:07\begin{sloppypar) ... \end{sloppypar}. it won't look so good though. – barbara beeton Jul 24 '15 at 09:24