创建新文件
文件类型
文件
文件夹
创建名称
Search file in folder and subfolders...
Are you sure want to rename?
文件管理器
/
PreviewFiles
/
05-文本与代码
:
ruby.rb
Advanced Search
上传
创建新文件/文件夹
设置
返回
备份
高级编辑器
Save
# Using re's to break up a line. print "Please enter a line: " line = gets.chomp res = [ ] while res != '' # String leading blanks. line.sub!(/^\s*/, '') break if line == '' # See what the leading is for next action. if line[0].chr == '"' then # Quoted. line.sub!(/^"([^"]*)"/, '') res.push($1) elsif line.sub!(/^(\d+):(\S+)/, '') # Repeated with n: $1.to_i.times { res.push($2) } else # Just a word. line.sub!(/^(\S+)/, '') res.push($1) end end res.each { |x| print " [", x, "]\n" }