re = /name[0-9]+\:([^:]{0,30})/i
str = '28:announce39://torrent.ubuntu.com:6969/announce13:announce-listll39://torrent.ubuntu.com:6969/announceel44://ipv6.torrent.ubuntu.com:6969/announceee7:comment29:Ubuntu CD releases.ubuntu.com13:creation datei1382003607e4:infod6:lengthi925892608e4:name30:ubuntu-13.10-desktop-amd64.iso12:piece lengthi524288e6:pieces35320:I½ÊŒÞJÕ`9'
# Print the match result
str.match(re) do |match|
puts match.to_s
end
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