Anonymous user
Substring/Top and tail: Difference between revisions
m
Minor tidying
No edit summary |
m (Minor tidying) |
||
Line 1:
{{draft task}}[[Category:String manipulation]]
The task is to demonstrate how to remove the first and last characters from a string. The solution should demonstrate how to obtain the following results:
Line 6 ⟶ 5:
* String with last character removed
* String with both the first and last characters removed
=={{header|ZX Spectrum Basic}}==▼
<lang zxbasic>10 PRINT FN f$("knight"): REM strip the first letter▼
20 PRINT FN l$("socks"): REM strip the last letter▼
30 PRINT FN b$("brooms"): REM strip both the first and last letter▼
100 STOP▼
9000 DEF FN f$(a$)=a$(2 TO LEN(a$))▼
9010 DEF FN l$(a$)=a$(1 TO LEN(a$)-(1 AND (LEN(a$)>=1)))▼
9020 DEF FN b$(a$)=FN l$(FN f$(a$)) </lang>▼
=={{header|Perl}}==
Line 45 ⟶ 33:
room</pre>
▲=={{header|ZX Spectrum Basic}}==
▲<lang zxbasic>10 PRINT FN f$("knight"): REM strip the first letter
▲20 PRINT FN l$("socks"): REM strip the last letter
▲30 PRINT FN b$("brooms"): REM strip both the first and last letter
▲100 STOP
▲9000 DEF FN f$(a$)=a$(2 TO LEN(a$))
▲9010 DEF FN l$(a$)=a$(1 TO LEN(a$)-(1 AND (LEN(a$)>=1)))
▲9020 DEF FN b$(a$)=FN l$(FN f$(a$)) </lang>
|