Replace multiple spaces with one space in a string

前端 未结 5 1511
感动是毒
感动是毒 2020-12-01 03:54

How would I do something in c++ similar to the following code:

//Lang: Java
string.replaceAll(\"  \", \" \");

This code-snippe

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 04:38

    Why not use a regular expression:

    boost::regex_replace(str, boost::regex("[' ']{2,}"), " ");

提交回复
热议问题