Logo

Programming-Idioms

History of Idiom 38 > diff from v62 to v63

Edit summary for version 63 by programming-idioms.org:
[C++] +DemoURL. Also, wrong.

Version 62

2020-10-24, 19:25:54

Version 63

2020-11-26, 12:00:49

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)

Illustration

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)

Illustration
Variables
t,i,j,s
Variables
t,i,j,s
Imports
Imports
#include <string>
Code
auto t = s.substr(i, j-i);
Code
auto t = s.substr(i, j-i);
Comments bubble
This does not properly handle UTF-8 characters
Doc URL
http://www.cplusplus.com/reference/string/string/substr/
Doc URL
http://www.cplusplus.com/reference/string/string/substr/
Demo URL
https://repl.it/@ProgIdioms/KosherLovingCopycat