I want to replace the hyphen between 2 characters in a string. The 2 characters can be anything but a space.
string.replace(/regex/g, '');
so
- dog-cat : dogcat
- dog - cat : unchanged
- 1-1 : 11
- 1 - 1 : unchanged
- $-$ : $$
- $ - $ : unchanged
- ^-^ : ^^
- ^ - ^ : unchanged
- etc...
str = str.replace(/(\S)-(\S)/g, '$1$2');11-11for1-1-1-1input, do you really want that? See my answer.