There is no automatic solution unless you slightly modify the string. Inside the strings replace all standard hyphens by U+2011 NON-BREAKING HYPHEN (this is the same as Ctrl+Shift+-) and all standard spaces by U+00A0 NO-BREAK SPACE (same as Ctrl+Shift+ ).
You may find that no-break space is wider than ordinary space in certain fonts. Unfortunately you can’t use other spaces defined starting at U+2000 because these spaces (with various widths) have not the no-break property.
Since these no-break characters are considered formatting marks, the UI gives them the same backgrounds as fields. This background doesn’t print, so it is harmless, just a reminder you have a “special” character. In case, you handle your document only on screen and find this background disturbing, you can disable it with View>Field Shadings. Note it is generally a bad idea.
If your string contains non alphanumerical characters besides hyphen, like punctuation, Insert>Formatting Marks>No-width No Break after the punctuation. For bulk insertion, this is U+2060 WORD JOINER.
Another approach could be to systematically insert U+2060 after every character of the string, except the last one so that you don’t think about which character should be “marked” or not. This can be done with Find & Replace.
A final note: your strings have a special meaning in your document (obviously they are not human meaningful words). It would be a good idea to mark up them with a dedicated character style in which language is set to None in order to silence spell-checking. Unfortunately, it is not possible to give a no-break property through a style.