ÃÑ ÆäÀÌÁö ¼ö : 3224
![]()
|
Facebook Joinc ±×·ì
Joinc QA »çÀÌÆ®
![]()
Tweet
joinc´Â Firefox¿Í chrome¿¡¼ Å×½ºÆ® Çß½À´Ï´Ù. IE¿¡¼´Â Å×À̺íÀÌ ±úÁö°Å³ª À̹ÌÁö°¡ º¸ÀÌÁö ¾ÊÀ» ¼ö ÀÖ½À´Ï´Ù. ƯÈ÷ ±¸±Û DocsÀ̹ÌÁöÀÇ °æ¿ì ¿¢¹Úó¸®µÉ ¼ö ÀÖ½À´Ï´Ù. Stringindex (substring [,offset]) -> fixnum or nilindex (regexp [,offset]) -> fixnum or nil
¹®ÀÚ¿¿¡¼ substring¸¦ ã´Â´Ù. Á¤±ÔÇ¥Çö½ÄÀ» »ç¿ëÇÒ ¼öµµ ÀÖ´Ù. ¹ß°ßÇÏ¸é ¹ß°ßÇÑ À§Ä¡ÀÇ index °ªÀ» ¹ÝȯÇÑ´Ù. ¹ß°ßÇÏÁö ¸øÇß´Ù¸é nilÀ» ¹ÝȯÇÑ´Ù. "hello".index('e') #=> 1
"hello".index('lo') #=> 3
"hello".index('a') #=> nil
"hello".index(?e) #=> 1
"hello".index(/[aeiou]/, -3) #=> 4
split (pattern=$;, limit) -> anArray
StringÀ» ±¸ºÐÀÚ¸¦ ±âÁØÀ¸·Î ³ª´«´Ù. °á°ú°ªÀº ±¸ºÐÀÚ·Î ºÐ¸®µÈ ¹®ÀÚ¿ÀÇ ¹è¿ÀÌ´Ù.
¸¸¾à pattern¾øÀÌ split¸¦ È£ÃâÇϸé, °ø¹é¹®ÀÚ¸¦ ±¸ºÐÀÚ·Î ¼³Á¤ÇÑ´Ù. patternÀº (Regexp)Á¤±ÔÇ¥Çö½ÄÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù.
¸¸¾à limit¸¦ »ç¿ëÇϸé, limit °³¼ö¸¸Å ¸¸ split¸¦ ÁøÇàÇÑ´Ù. " now's the time".split #=> ["now's", "the", "time"]
" now's the time".split(' ') #=> ["now's", "the", "time"]
" 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,,".split(',', 4) #=> ["1", "2", "", "3,4,,"]
"1,2,,3,4,,".split(',', -4) #=> ["1", "2", "", "3", "4", "", ""]
|
|
|
EmailÀ» ±âÀÔÇϸé, ´ñ±ÛÀÌ ¸ÞÀÏ·Î Àü´ÞµË´Ï´Ù. |
|