Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

-4 Thanks @Shaggy
Source Link
Shieru Asakoto
  • 6.5k
  • 19
  • 43

JavaScript (Node.js), (削除) 38 (削除ここまで) 36(削除) 36 (削除ここまで) 32 bytes

(削除) s=>s.replace(/(.)(.)( |$)/g,"2ドル1ドル ")  (削除ここまで)
s=>s.replace(/(.)(.)( |$)\b/g,"2ドル1ドル ""2ドル1ドル")

Try it online!

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ドル ")

Try it online!

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ドル")

Try it online!

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

-2 for only considering 1 space and add trailing space, add courtesy
Source Link
Shieru Asakoto
  • 6.5k
  • 19
  • 43

JavaScript (Node.js), 38(削除) 38 (削除ここまで) 36 bytes

s=>s.replace(/(.)(.)(\s|$ |$)/g,"2ドル1ドル3ドル""2ドル1ドル ")

Try it online! Try it online!

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ドル")

Try it online!

RegExp approach, assuming words separated by only 1 space.

JavaScript (Node.js), (削除) 38 (削除ここまで) 36 bytes

s=>s.replace(/(.)(.)( |$)/g,"2ドル1ドル ")

Try it online!

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

Source Link
Shieru Asakoto
  • 6.5k
  • 19
  • 43

JavaScript (Node.js), 38 bytes

s=>s.replace(/(.)(.)(\s|$)/g,"2ドル1ドル3ドル")

Try it online!

RegExp approach, assuming words separated by only 1 space.

AltStyle によって変換されたページ (->オリジナル) /