Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Cobol

Idiom #47 Extract string suffix

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

The end of the string s
IDENTIFICATION DIVISION.
PROGRAM-ID. suffix.
PROCEDURE DIVISION.
    MOVE FUNCTION LENGTH(s) TO len
    COMPUTE pos = (len - 5) + 1
    MOVE    s(pos:) TO t    	 	
STOP RUN.
(let [t (clojure.string/join (take-last 5 s))])

New implementation...