V
V
Vladimir A2017-09-30 14:33:38
C++ / C#
Vladimir A, 2017-09-30 14:33:38

How to cut all lines except first and last in string?

Example string(each new "line" is separated by \n )

0,100,777,555
1,101,777,555
2,102,777,555
3,103,777,555
4,104,777,555
5,105,777,555
6,106,777,555
7,107,777,555
8,108,777,555
9,109,777,555
10,110,777,555
11,111,777,555
18,118,777,555
19,119,777,555
20,120,777,555
21,121,777,555
22,122,777,555
23,123,777,555

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
devalone, 2017-09-30
@hauptling

something like that:

size_t firstIndex = origString.find_first_of('\n');
size_t lastIndex = origString.find_last_of('\n');
std::string cuttedString = origString.substr(firstIndex, lastIndex - firstIndex)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question