- Ruby API 文档 http://www.ruby-doc.org/core-2.0.0/
- Programming Ruby http://ishare.iask.sina.com.cn/f/22783772.html
- 替换字符串某一部分的方法
puts "hello".sub(/l/, '*')
puts "hello".gsub(/l/, '*') puts "hello".sub(/lll/, '*')
puts "hello".gsub(/lll/, '*') #return itself if no gsub
puts "hello".sub!(/lll/, '*')
puts "hello".gsub!(/lll/, '*') #return nil if no gsub
sleep 10 - 正则表达式 http://www.ruby-doc.org/core-2.0.0/Regexp.html
- Regexps are created using the
/.../
and%r{...}
literals, and by theRegexp::new
constructor.
- Regexps are created using the
- 区间 http://www.ruby-doc.org/core-2.0.0/Range.html
- Ranges may be constructed using the s
..
e and s...
e literals, or with ::new.
- Ranges may be constructed using the s
- 打印字符串
puts "hello"
相关文章
- 08-28Ruby-1