JiaHeng-DLUT
9/17/2019 - 3:01 AM

What's the best way to trim std::string❓

#include <bits/stdc++.h>
using namespace std;

int main() {
	string s = "  Hello world!  ";
	s.erase(0, s.find_first_not_of(" \n\r\t"));
	cout << s;	/*Hello world!  */
	s.erase(s.find_last_not_of(" \n\r\t") + 1);
	cout << s;	/*Hello world!*/
	return 0;
}