Skip to content

Instantly share code, notes, and snippets.

@SyunWatanabe
Created February 15, 2020 07:40
Show Gist options
  • Select an option

  • Save SyunWatanabe/943d93c4757f972603ac74eaab908245 to your computer and use it in GitHub Desktop.

Select an option

Save SyunWatanabe/943d93c4757f972603ac74eaab908245 to your computer and use it in GitHub Desktop.
# 正規表現変換
old_syntax = <<TEXT
{
:name => 'Alice',
:age=>20,
:gender => :female
}
TEXT
def convert_hash_syntax(old)
old.gsub(/:(\w+) *=> */, '\1: ')
end
puts convert_hash_syntax(old_syntax)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment