File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -291,4 +291,32 @@ Returns the codepoint number of the first character of the string
291
291
292
292
Returns a list of codepoint numbers, one for each character in the string.
293
293
294
+ = head2 trim
295
+
296
+ method trim(Str:D:) returns Str
297
+
298
+ Remove leading and trailing white-spces. It can be use both as a method
299
+ on strings and as a function. When used as a method it will return
300
+ the trimmed string. In order to do in-place trimming, once needs to write
301
+ C < .=trim >
302
+
303
+
304
+ my $line = ' hello world ';
305
+ say '<' ~ $line.trim ~ '>'; # <hello world>
306
+ say '<' ~ trim($line) ~ '>'; # <hello world>
307
+ $line.trim;
308
+ say '<' ~ $line ~ '>'; # < hello world >
309
+ $line.=trim;
310
+ say '<' ~ $line ~ '>'; # <hello world>
311
+
312
+ See also L < trim-trailing > and L < trim-leading >
313
+
314
+ = head2 trim-trailing
315
+
316
+ Remove the white-space charecters from the end of a string. See also L < trim > .
317
+
318
+ = head2 trim-leading
319
+
320
+ Remove the white-space charecters from the beginning of a string. See also L < trim > .
321
+
294
322
= end pod
You can’t perform that action at this time.
0 commit comments