Camelia
Prev: String functions: index

String functions: substr

examples/scalars/string_functions_substr.p6
#!/usr/bin/env perl6
use v6;

my $s = "The black cat climbed the green tree";
my $z;
$z = substr $s, 4, 5;                    # $z = black
say $z;
$z = substr $s, 4, *-11;                 # $z = black cat climbed the
say $z;
$z = substr $s, 14;                      # $z = climbed the green tree
say $z;
$z = substr $s, *-4;                     # $z = tree
say $z;
$z = substr $s, *-4, 2;                  # $z = tr
say $z;


Prev: String functions: index

Table of Contents

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.
Email:
Name: