Hello, i have a problem constructing a regular expression to strip out puntuations from a document.Below is a simple example of my code

#
//headers here
//...

string a="kennedy .really-really. .cool";
string replace=" ";
string newStr;
boost::regex expression("[ ]+(\\.)|(\\.)[ ]+",boost::regex::icase);
newStr=boost::regex_replace(a,expression,replace);
cout << newStr << endl;

//output
kennedy really-really .cool

//Expected output
kennedy really-really cool

I dont intend to remove puntuations between two word like "really-really" , "re-instal". How do i go about this?

Thanks in advance

Have you tried <algorithm>'s remove?

Something like:

string.erase(remove(string.begin(), string.end(), "-."), string.end());

By the way, you don't need Boost.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.