JavaScript (Node.js), (削除) 38 (削除ここまで) 36(削除) 36 (削除ここまで) 32 bytes
(削除) s=>s.replace(/(.)(.)( |$)/g,"2ドル1ドル ") (削除ここまで)
s=>s.replace(/(.)(.)( |$)\b/g,"2ドル1ドル ""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
JavaScript (Node.js), (削除) 38 (削除ここまで) 36 bytes
s=>s.replace(/(.)(.)( |$)/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
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
- 6.5k
- 19
- 43
JavaScript (Node.js), 38(削除) 38 (削除ここまで) 36 bytes
s=>s.replace(/(.)(.)(\s|$ |$)/g,"2ドル1ドル3ドル""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
JavaScript (Node.js), 38 bytes
s=>s.replace(/(.)(.)(\s|$)/g,"2ドル1ドル3ドル")
RegExp approach, assuming words separated by only 1 space.
JavaScript (Node.js), (削除) 38 (削除ここまで) 36 bytes
s=>s.replace(/(.)(.)( |$)/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
JavaScript (Node.js), 38 bytes
s=>s.replace(/(.)(.)(\s|$)/g,"2ドル1ドル3ドル")
RegExp approach, assuming words separated by only 1 space.