Logo

Programming-Idioms

History of Idiom 38 > diff from v37 to v38

Edit summary for version 38 by :
New Csharp implementation by user [javasucks]

Version 37

2016-02-17, 15:52:48

Version 38

2016-02-18, 16:57:59

Idiom #38 Extract a substring

Find substring t consisting in characters i (included) to j (excluded) of string s.
(character indexes start at 0 unless specified otherwise)

Idiom #38 Extract a substring

Find substring t consisting in characters i (included) to j (excluded) of string s.
(character indexes start at 0 unless specified otherwise)

Code
T : String := S (I .. J - 1);
Comments bubble
In Ada, strings use 1-based indexing

In Ada, J is included by default when slicing
Code
my $chunk = substr("now is the time", $i, $j);
Code
my $chunk = substr("now is the time", $i, $j);
Comments bubble
Perl is 0-based: i=3 would start at the 4th character.
Comments bubble
Perl is 0-based: i=3 would start at the 4th character.
Doc URL
http://perldoc.perl.org/functions/substr.html
Doc URL
http://perldoc.perl.org/functions/substr.html