ת×Ô£º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
´Ó½ñÌìÆð²»ÔÙÀË·Ñʱ¼ä£¬¿ªÊ¼×ßÏò×Ô¶¯»¯²âÊÔÕâÌõ¹âÃ÷µÄµÀ·£¬²¢ÒԴһ¸ö×Ô¶¯»¯²âÊÔƽ̨ΪĿ±ê£¬²¢Õâ¸ö¹ý³ÌÒ»µãµãµÄ¼Ç¼ÏÂÀ´ºÍ´ó¼Ò·ÖÏí
Ê×ÏÈ£¬ÊÇruby»·¾³µÄ´î½¨
£¨1£©µ½rubyµÄ¹ÙÍø£ºhttp://www.ruby-lang.org/en/ÏÂÔØ ruby°²×°³ÌÐò;
PS £ºÑ¡Ôñ ruby on windows,ÎÒÏÂÔصÄÊÇRuby 1.8.6 One ......