写了个去除左侧无效字符(空格,回车,TAB)的正则表达式。
std::
string
testString
=
"
\r\n Hello World ! GoodBye World\r\n
"
;
std:: string TrimLeft = " ([\\s\\r\\n\\t]*)(\\w*.*) " ;
boost::regex expression(TrimLeft);
testString = boost::regex_replace( testString, expression, " $2 " );
std::cout << " TrimLeft: " << testString << std::endl;
打印输出:
std:: string TrimLeft = " ([\\s\\r\\n\\t]*)(\\w*.*) " ;
boost::regex expression(TrimLeft);
testString = boost::regex_replace( testString, expression, " $2 " );
std::cout << " TrimLeft: " << testString << std::endl;
TrimLeft:Hello World ! GoodBye World
问题是去除右侧无效字符的正则表达式该怎么写?哪位大侠显个灵,帮助写写看,多谢了。