首页 > 解决方案 > How to put a space between hyphen and next character unless it's a multi-word?

问题描述

I have a text that contains both multi-words and dialog-like phrases like -hello and I want to separate hyphen from the word only if it's not part of the multi-word, meaning hyphen is not surrounded by two chars.

The word could appear anywhere in the sentence, not just the beginning. Example:

input:

multi-media
-hello -oh, hi

desired output:

multi-media
- hello - oh, hi

Can this be accomplished using sed or awk?

标签: regexawksed

解决方案



推荐阅读