易截截图软件、单文件、免安装、纯绿色、仅160KB

转载——Ruby字符串处理

转自:http://developer.51cto.com/art/200912/170762.htm 
Ruby字符串处理函数总结列表分享
Ruby字符串处理函数包括返回字符串长度函数;判断字符串中是否包含另一个串函数;字符串插入;字符串分隔,默认分隔符为空格等等。
 
str.length => integer 
str.include? other_str
 => true or false  
"hello".include? "lo"
 #=> true  
"hello".include? "ol"
 #=> false  
"hello".include? ?h
 #=> true 
Ruby语言对于编程人员来说是一项非常有用的函数。学好这项语言可以帮助我们实现简便轻松的编写方式。下面我们向大家介绍一下Ruby字符串处理函数的一些基本概念。
Ruby字符串处理函数1.返回字符串的长度
Ruby字符串处理函数2.判断字符串中是否包含另一个串
Ruby字符串处理函数3.字符串插入:
str.insert(index, other_str) 
=> str   "abcd".insert(0, 'X')
 #=> "Xabcd"  "abcd".insert(3, 'X')
 #=> "abcXd"  "abcd".insert(4, 'X') 
#=> "abcdX"  "abcd".insert(-3, 'X')    -3, 'X') #=> "abXcd"  "abcd".insert(-1, 'X')
 #=> "abcdX" 
Ruby字符串处理函数4.字符串分隔,默认分隔符为空格
str.split(pattern=$;, [limit])
 => anArray   " now's the time".split #=> 
["now's", "the", "time"]  "1, 2.34,56, 7".split(%r{,\s*})
 #=> ["1", "2.34", "56", "7"]  "hello".split(//) #=> 
["h", "e", "l", "l", "o"]  "hello".split(//, 3) #=> 
["h", "e", "llo"]  "hi mom".split(%r{\s*}) #=> 
["h", "i", "m", "o", "m"]   "mellow yellow".split("ello")
 #=> ["m", "w y", "w"]  "1,2,,3,4,,".split(',') #=>
 ["1", "2", "", "3", "4"]  "1,2,,3,4,,".spl


相关文档:

rails on ruby exmaples depot

1.install ruby
    download from http://www.ruby-lang.org/en/news/2009/12/07/ruby-1-9-1-p376-is-released/
2.install rails
   ruby gem install rails --include-dependencies
3.install mysql
   download from http://sourceforge.net
   ruby gem install&nb ......

升级到snow leopard后ruby的问题

1. ruby已成为1.87 2. 必须先安装安装光盘里的新的xcode,在"optional"目录里 3. 可能需要重新安装macport http://trac.macports.org/wiki/Migration 4. 或者升级macport http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard $ sudo port selfupdate
$ sudo port sync
$ sudo port upgrade --force insta ......

Ruby 命令行 常用命令

从命令行启动Ruby解释器时,你不仅可以提供程序文件的名字,而且可以提供一个或多个命令行开关。你选择的开关指示解释器以一种特定的方式运转,并且/或者执行特定的操作。
Ruby命令行开关有20多个,其中有些很少使用,有些则每天被很多Ruby程序员使用。在这里我们将再看几个最常用的。(你已经看到过其中的两个,-c和&ndas ......

linux(ubuntu)下ruby开发环境搭建

env setup
linux(ubuntu)下ruby开发环境搭建,包括一些常见问题解决
注意,本文只是我在搭建ruby学习环境时的一些笔记,因为是用gedit编辑的,所以格式化不是很好,另外,只是备忘而已。
2010.1.19
1. install ruby
$ tar xzf ruby-1.8.7-p248.tar.gz
$ mv ruby-1.8.7-p248 ruby187
$ cd ruby187/
$ ./configure ......

Ruby 一步步安装


http://www.gayathri-frenzy.com/technology/ruby-on-rails
I kept thinking for a while on what do I have next in the store
Here we go “Ruby on Rails”
Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby Programming language.Ruby is a ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号