Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added usage to C<split>
Added TODO for LIMIT to C<split>
Put code tags around examples in C<split>
  • Loading branch information
dha committed Oct 2, 2015
1 parent 5d17958 commit 81278cc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/Type/Str.pod
Expand Up @@ -192,19 +192,29 @@ Examples:
multi method split(Str:D $input: Str:D $delimiter, $limit = Inf, :$all) returns Positional
multi method split(Str:D $input: Regex:D $delimiter, $limit = Inf, :$all) returns Positional
Usage:
split( DELIMITER, EXPR [, LIMIT] [, :all])
split( PATTERN, EXPR [, LIMIT] [, :all])
EXPR.split( DELIMITER [, LIMIT] [, :all])
EXPR.split( PATTERN [, LIMIT] [, :all])
Splits a string up into pieces based on delimiters found in the string.
If C<$delimiter> is a string, it is searched for literally and not treated
If C<DELIMITER> is a string, it is searched for literally and not treated
as a regex.
If the named parameter C<:all> is passed, the matches from C<$delimiter>
If the named parameter C<:all> is passed, the matches from C<DELIMITER>
are included in the result list.
Note that unlike in Perl 5, empty chunks are not removed from the result list.
If you want that behavior, consider using L<comb> instead.
=comment TODO Describe behavior of LIMIT
Examples:
=begin code
say split(';', "a;b;c").perl; # ("a", "b", "c").list
say split(';', "a;b;c", :all).perl; # (("a", ";"), ("b", ";"), "c").list
say split(';', "a;b;c", 2).perl; # ("a", "b;c").list
Expand All @@ -213,6 +223,7 @@ Examples:
say split(';', "a;b;c,d").perl; # ("a", "b", "c,d").list
say split(/\;/, "a;b;c,d").perl; # ("a", "b", "c,d").list
say split(/<[;,]>/, "a;b;c,d").perl; # ("a", "b", "c", "d").list
=end code
=head2 routine comb
Expand Down

0 comments on commit 81278cc

Please sign in to comment.