Logo

Programming-Idioms

History of Idiom 38 > diff from v32 to v33

Edit summary for version 33 by :
New Go implementation by user [lck]

Version 32

2016-01-01, 22:25:05

Version 33

2016-01-02, 00:37:57

Idiom #38 Extract a substring

Find substring t consisting in characters i (included) to j (excluded) of string s.
(character indexes start at 0 unless specified otherwise)

Idiom #38 Extract a substring

Find substring t consisting in characters i (included) to j (excluded) of string s.
(character indexes start at 0 unless specified otherwise)

Code
t := string([]rune(s)[i:j])
Comments bubble
convert to []rune because some characters are two or more bytes.
Demo URL
https://play.golang.org/p/HYgE2xPN1_