Logo

Programming-Idioms

  • Lisp
  • Python
  • Js

Idiom #46 Extract beginning of string (prefix)

Create the string t consisting of the 5 first characters of the string s.
Make sure that multibyte characters are properly handled.

let t = s.substring(0,5);
(setf *t* (subseq s 0 5))
t = s[:5]
T : String := S (1 .. 5);

New implementation...