c++ 去掉字符串首尾空格

#include <iostream>
#include <regex>

using namespace std;

	string mask = " 01 02 03 ?? ?? 0? 2? 88  ";
	cout << mask << "|" << endl;
	mask = regex_replace(mask, regex("^\\s+"), "");
	mask = regex_replace(mask, regex("\\s+$"), "");
	cout << mask << "|" << endl;
 01 02 03 ?? ?? 0? 2? 88  |
01 02 03 ?? ?? 0? 2? 88|
posted @ 2020-08-29 14:28  Ajanuw  阅读(319)  评论(0编辑  收藏  举报