re = /\[(\/?\w+\:?\w+)\]/m
str = '
[shake2][wave]朝から私の大好きな[scream][big]死[/scream][/big]のにおいがするな...[/wave][/shake2]
[shake2]お前を殺すには骨がおれるが、しかし利益は大きい。ハッハッハ![/shake2]
[shake2]おや、心がおれそうだって?もう全てを放り出してあきらめたらどうだ。キッド[/shake2]
[shake2]そんなに死んでしまうのが好きなら、死とチューしちゃえばいいのに![/shake2]
何か無くなった気がするだって?もし、お前が[icon:camerabadge]カメラバッジを持っているなら、撮影ポーズ中に見回して、その[name]何か[/name]を探してみればいい...
\\[(\\w+)\\](.*)\\[\\/\\1\\]'
subst = '$2'
result = str.gsub(re, subst)
# Print the result of the substitution
puts result
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html