• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
暗夜Elf
博客园 首页 新随笔 联系 订阅 订阅 管理

Ruby-1

  • 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.
  • 区间 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. 
  • 打印字符串    
    puts "hello"

     

      
发表于 2013-09-17 20:24  暗夜Elf  阅读(180)  评论(0)    收藏  举报
 
刷新页面返回顶部

公告


博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3