JavaScript (Node.js), (削除) 38 (削除ここまで) (削除) 36 (削除ここまで) 32 bytes
(削除) s=>s.replace(/(.)(.)( |$)/g,"2ドル1ドル ") (削除ここまで)
s=>s.replace(/(.)(.)\b/g,"2ドル1ドル")
RegExp approach courtesy @Giuseppe (although I thought of this independently), assuming words separated by only one space
-2 for only considering 1 space and add trailing space
-4 Thanks @Shaggy
Shieru Asakoto
- 6.5k
- 19
- 43