diff options
| author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-25 17:27:50 +0000 |
|---|---|---|
| committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-25 17:27:50 +0000 |
| commit | 185ed6e270577f38132e4a559249c32591314bcd (patch) | |
| tree | 943ab0119c9d62b965140d902e43246d90004dd6 /string.c | |
| parent | 456385357465032b64252023b1dc13f59d599b11 (diff) | |
* string.c (rb_str_split): add rdoc.
patched by Hugh Sasse [ruby-core:27819]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -3614,7 +3614,9 @@ rb_str_count(argc, argv, str) * * If <i>pattern</i> is a <code>Regexp</code>, <i>str</i> is divided where the * pattern matches. Whenever the pattern matches a zero-length string, - * <i>str</i> is split into individual characters. + * <i>str</i> is split into individual characters. If + * <i>pattern</i> includes one or more capturing subpatterns, + * these will be returned in the array returned by split. * * If <i>pattern</i> is omitted, the value of <code>$;</code> is used. If * <code>$;</code> is <code>nil</code> (which is the default), <i>str</i> is @@ -3631,6 +3633,8 @@ rb_str_count(argc, argv, str) * " 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"] + * "1, 2.34,56".split(%r{(,\s*)}) #=> ["1", ", ", "2.34", ",", "56"] + * "wd :sp: wd".split(/(:(\w+):)/) #=> ["wd ", ":sp:", "sp", " wd"] * "hello".split(//) #=> ["h", "e", "l", "l", "o"] * "hello".split(//, 3) #=> ["h", "e", "llo"] * "hi mom".split(%r{\s*}) #=> ["h", "i", "m", "o", "m"] |
