Substring/Top and tail: Difference between revisions

Content added Content deleted
(GP)
({{header|Lua}})
Line 42: Line 42:
alert("socks".slice(0, -1)); // strip last character
alert("socks".slice(0, -1)); // strip last character
alert("brooms".slice(1, -1)); // strip both first and last characters</lang>
alert("brooms".slice(1, -1)); // strip both first and last characters</lang>

=={{header|Lua}}==

<lang lua>print (string.sub("knights",2)) -- remove the first character
print (string.sub("knights",1,-2)) -- remove the last character
print (string.sub("knights",2,-2)) -- remove the first and last characters</lang>


=={{header|PARI/GP}}==
=={{header|PARI/GP}}==