我在C++ STL中不太好。 我有串状:替换字符串中的空格
x ,y z , a ,b, some text ,
我想除了这两个词 所以我想输出为之间的空间被删除在这一切的空间:
x,y z,a,b,some text,
我可以很容易做到这一点在Perl中:
perl -pe 's/\s*,\s*/,/g;s/^\s*//g'
但我需要它在C++中。
我所能做的到现在是:
line.erase(remove_if(line.begin(), line.end(), isspace), line.end());
但这删除的行中的所有splaces。
我使用的编译器:
> CC -V
CC: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25
不具有正则表达式头
[boost](http://stackoverflow.com/questions/11321533/how-to-use-boost-regular-expression-r E放置方法)? – Dukeling
可能的重复http://stackoverflow.com/questions/5891610/how-to-remove-characters-from-a-string –
而这里http://stackoverflow.com/questions/236129/splitting-a-string- in-c – doctorlove