[TT #592][docs] Clarify docs about the case sensitivity of the debugger
[parrot.git] / examples / tutorial / 23_string_ops_substr.pir
blob036c86b6f70d1f06608d281f5ac0ce7728fe1412
1 # Copyright (C) 2007-2009, Parrot Foundation.
2 # $Id$
4 =head1 String Operations (continued)
6 We can pick apart a string and pull substrings out of it using the
7 C<substr> command. C<substr> takes a string, a starting position and
8 optionally an ending position. It returns all the characters in
9 the string between the starting and ending positions. If the ending
10 position is left out, C<substr> returns all the characters until the
11 end of the string.
13 An optional fourth argument is a string that will be used to
14 replace the characters between the start and end positions.
16 =cut
18 .sub main :main
20     $S0 = substr "abcde", 1, 2    # "bc"
21     say $S0
23     set $S1, "abcde"
24     $S0 = substr $S1, 1, 2
25     say $S0                   # "bc"
26     say $S1                   # "abcde"
28     set $S1, "abcde"
29     $S0 = substr $S1, 1, 2, "XYZ"
30     say $S0                       # "bc"
31     say $S1                       # "aXYZde"
33 .end
35 # Local Variables:
36 #   mode: pir
37 #   fill-column: 100
38 # End:
39 # vim: expandtab shiftwidth=4 ft=pir: