Skip to main content
2 of 2
Commonmark migration

rs, 20 bytes

#
+#(.*)(.)/\2#\1
#/

Technically, this doesn't count (rs was created earlier this year), but I didn't see any other regex-based answers, and I thought this was neat.

Live demo.

Explanation:

#

Insert a pound character at the beginning of the string. This is used as a marker.

+#(.*)(.)/\2#\1

Continuously prepend the last character of the main string to the area before the marker until there are no characters left.

#/

Remove the marker.

kirbyfan64sos
  • 9.2k
  • 1
  • 26
  • 46