@@ -199,6 +199,13 @@ C<$limit> matches.
199
199
If no matcher is supplied, a list of characters in the string
200
200
(ie C < $delimiter = rx/./ > ) is returned.
201
201
202
+ Examples:
203
+
204
+ comb(/\w/, "a;b;c").perl; # ("a", "b", "c").list
205
+ comb(/\N/, "a;b;c").perl; # ("a", ";", "b", ";", "c").list
206
+ comb(/\w/, "a;b;c", 2).perl; # ("a", "b").list
207
+ comb(/\w\;\w/, "a;b;c", 2).perl; # ("a;b",).list
208
+
202
209
= head2 lines
203
210
204
211
multi sub lines(Str:D $input, $limit = Inf) returns Positional
@@ -207,6 +214,14 @@ If no matcher is supplied, a list of characters in the string
207
214
Returns a list of lines (without trailing newline characters), i.e. the
208
215
same as a call to C < $input.comb( / ^^ \N* /, $limit ) > would.
209
216
217
+ Examples:
218
+
219
+ lines("a\nb").perl; # ("a", "b").list
220
+ lines("a\nb").elems; # 2
221
+ "a\nb".lines.elems; # 2
222
+
223
+ "a\n".lines.elems; # 1
224
+
210
225
= head2 words
211
226
212
227
multi sub words(Str:D $input, $limit = Inf) returns Positional
@@ -215,13 +230,25 @@ same as a call to C<$input.comb( / ^^ \N* /, $limit )> would.
215
230
Returns a list of non-whitespace bits, i.e. the same as a call to
216
231
C < $input.comb( / \S+ /, $limit ) > would.
217
232
233
+ Examples:
234
+
235
+ "a\nb\n".words.perl; # ("a", "b").list
236
+ "hello world".words.perl; # ("hello", "world").list
237
+ "foo:bar".words.perl; # ("foo:bar",).list
238
+ "foo:bar\tbaz".words.perl; # ("foo:bar", "baz").list
239
+
218
240
= head2 flip
219
241
220
242
multi sub flip(Str:D ) returns Str:D
221
243
multi method flip(Str:D:) returns Str:D
222
244
223
245
Returns the string reversed character by character.
224
246
247
+ Examples:
248
+
249
+ "Perl".flip; # lreP
250
+ "ABBA".flip; # ABBA
251
+
225
252
= head2 sprintf
226
253
227
254
multi sub sprintf ( Str:D $format, *@args) returns Str:D
@@ -297,6 +324,13 @@ Examples:
297
324
Returns a part of the string, starting from the character with index C < $from >
298
325
(where the first character has index 0) and with length C < $chars > .
299
326
327
+ Examples:
328
+
329
+ substr("Long string", 6, 3); # tri
330
+ substr("Long string", 6); # tring
331
+ substr("Long string", 6, *-1); # trin
332
+ substr("Long string", *-3, *-1); # in
333
+
300
334
= head2 succ
301
335
302
336
method succ(Str:D) returns Str:D
0 commit comments