+ 1

How to remove extra spaces?

How to remove extra spaces? Under the extra spaces means more spaces in a row, for example: I (two or more spaces) student! Dizzy already... you know... Session, exam. Left 4 tickets 40. Others have decided. translate Google ĐĄ++

17th Jan 2018, 4:37 PM
Expert
Expert - avatar
6 Answers
+ 1
@Cain Eviatar, this code removes all spaces.
17th Jan 2018, 5:20 PM
Expert
Expert - avatar
+ 1
@expert sorry about that, lemme fix it.
17th Jan 2018, 5:25 PM
Cain Eviatar
Cain Eviatar - avatar
0
im not familiar with c++, but you can do that with regex, something like : str.replace("\s{1,}", " "); if anyone can confirm
17th Jan 2018, 4:45 PM
Vincent
Vincent - avatar
0
you could use std::remove_if for that. or check each character in a string, here is example: https://code.sololearn.com/cAS2CykQpZQu/?ref=app
17th Jan 2018, 5:15 PM
Cain Eviatar
Cain Eviatar - avatar
0
@Cain Eviatar, wait. Thanks in advance!
17th Jan 2018, 6:07 PM
Expert
Expert - avatar