Skip to content

Instantly share code, notes, and snippets.

@hackjoy
Last active June 13, 2020 14:15
Show Gist options
  • Save hackjoy/1501059 to your computer and use it in GitHub Desktop.
Save hackjoy/1501059 to your computer and use it in GitHub Desktop.
Ruby [Method]: Insert/Add Characters into String
# Transforms ABCDEFGHIJKLMNOPQRSTUVWXY to ABCDE-FGHIJ-KLMNO-PQRS-UVWXY
# @number.change_to_licence
def change_to_licence
h = "-"
string = string.insert(5, h)
string = string.insert(11, h)
string = string.insert(17, h)
string = string.insert(23, h)
return string
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment