Substring/Top and tail: Difference between revisions
Content added Content deleted
m (→[[Remove_the_first_and_last_characters_from_a_string/Top_and_tail#ALGOL 68]]: use alternate word: carousers) |
|||
Line 13: | Line 13: | ||
<lang algol68>#!/usr/local/bin/a68g --script # |
<lang algol68>#!/usr/local/bin/a68g --script # |
||
STRING |
STRING str="carousers"; |
||
printf(($gl$, |
printf(($gl$, |
||
str, # remove no characters # |
|||
str[LWB str+1: ], # remove the first 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}}== |
||