Substring/Top and tail: Difference between revisions

Content added Content deleted
Line 13: Line 13:
<lang algol68>#!/usr/local/bin/a68g --script #
<lang algol68>#!/usr/local/bin/a68g --script #


STRING my string="knight";
STRING str="carousers";
printf(($gl$,
printf(($gl$,
my string[2:], # remove the first letter #
str, # remove no characters #
my string[ :UPB my string-1], # remove the last character #
str[LWB str+1: ], # remove the first character #
my string[2:UPB my string-1] # remove both the first and last character #
str[ :UPB str-1], # remove the last character #
str[LWB str+1:UPB str-1], # remove both the first and last character #
str[LWB str+2: ], # remove the first 2 characters #
str[ :UPB str-2], # remove the last 2 characters #
str[LWB str+2:UPB str-2] # remove both the first and last 2 characters #
))</lang>
))</lang>
Output:
Output:
<pre>
<pre>
carousers
night
arousers
knigh
carouser
nigh
arouser
rousers
carouse
rouse
</pre>
</pre>

=={{header|AWK}}==
=={{header|AWK}}==