Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
799ad0e1
Commit
799ad0e1
authored
Oct 27, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine `String#split` document
parent
8710a22c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
14 deletions
+6
-14
src/string.c
src/string.c
+6
-14
No files found.
src/string.c
View file @
799ad0e1
...
@@ -2108,23 +2108,18 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str)
...
@@ -2108,23 +2108,18 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str)
/*
/*
* call-seq:
* call-seq:
* str.split(
pattern="\n"
, [limit]) => anArray
* str.split(
separator=nil
, [limit]) => anArray
*
*
* Divides <i>str</i> into substrings based on a delimiter, returning an array
* Divides <i>str</i> into substrings based on a delimiter, returning an array
* of these substrings.
* of these substrings.
*
*
* If <i>
pattern
</i> is a <code>String</code>, then its contents are used as
* If <i>
separator
</i> is a <code>String</code>, then its contents are used as
* the delimiter when splitting <i>str</i>. If <i>
pattern
</i> is a single
* the delimiter when splitting <i>str</i>. If <i>
separator
</i> is a single
* space, <i>str</i> is split on whitespace, with leading whitespace and runs
* space, <i>str</i> is split on whitespace, with leading whitespace and runs
* of contiguous whitespace characters ignored.
* of contiguous whitespace characters ignored.
*
*
* If <i>pattern</i> is a <code>Regexp</code>, <i>str</i> is divided where the
* If <i>separator</i> is omitted or <code>nil</code> (which is the default),
* pattern matches. Whenever the pattern matches a zero-length string,
* <i>str</i> is split on whitespace as if ' ' were specified.
* <i>str</i> is split into individual characters.
*
* 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
* split on whitespace as if ' ' were specified.
*
*
* If the <i>limit</i> parameter is omitted, trailing null fields are
* If the <i>limit</i> parameter is omitted, trailing null fields are
* suppressed. If <i>limit</i> is a positive number, at most that number of
* suppressed. If <i>limit</i> is a positive number, at most that number of
...
@@ -2135,9 +2130,6 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str)
...
@@ -2135,9 +2130,6 @@ mrb_str_rindex(mrb_state *mrb, mrb_value str)
*
*
* " 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"]
* " now's the time".split(' ') #=> ["now's", "the", "time"]
* " now's the time".split(/ /) #=> ["", "now's", "", "the", "time"]
* "hello".split(//) #=> ["h", "e", "l", "l", "o"]
* "hello".split(//, 3) #=> ["h", "e", "llo"]
*
*
* "mellow yellow".split("ello") #=> ["m", "w y", "w"]
* "mellow yellow".split("ello") #=> ["m", "w y", "w"]
* "1,2,,3,4,,".split(',') #=> ["1", "2", "", "3", "4"]
* "1,2,,3,4,,".split(',') #=> ["1", "2", "", "3", "4"]
...
@@ -2150,7 +2142,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
...
@@ -2150,7 +2142,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
{
{
mrb_int
argc
;
mrb_int
argc
;
mrb_value
spat
=
mrb_nil_value
();
mrb_value
spat
=
mrb_nil_value
();
enum
{
awk
,
string
,
regexp
}
split_type
=
string
;
enum
{
awk
,
string
}
split_type
=
string
;
mrb_int
i
=
0
;
mrb_int
i
=
0
;
mrb_int
beg
;
mrb_int
beg
;
mrb_int
end
;
mrb_int
end
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment