One way to do this is using Boost. Tokenizer See this example.
One way to do this is using Boost.Tokenizer. See this example: #include #include #include int main() { using namespace std; using namespace boost; string text="n8Name4Surname. "; char_separator sep("0123456789"); tokenizer tokens(text, sep); string name, surname; int count = 0; BOOST_FOREACH(const string& s, tokens) { if(count == 1) { name = s; } if(count == 2) { surname = s; } ++count; } } EDIT If you put the results in a vector, its even less code: #include #include #include #include #include #include int main() { using namespace std; using namespace boost; string text="n8Name4Surname."; char_separator sep("0123456789"); tokenizer tokens(text, sep); vector names; tokenizer::iterator iter = tokens.begin(); ++iter; if(iter!
= tokens.end()) { copy(iter, tokens.end(), back_inserter(names)); } }.
– just me May 17 at 11:04 @just me: See the edit – Asha May 17 at 11:10.
You can detect numerical characters in the string using function isdigit(mystring. At(position), then extract substring between those positions. See: cplusplus.com/reference/clibrary/cctype/....
Use Boost tokenizer with the digits 0-9 as delimiters. Then, throw away the string containing "n". It's overkill, I realize...
We both think alike :) – Asha May 17 at 11:00 @Asha Yes, very nice :D – jonsca May 17 at 11:01.
Simple STL approach: #include #include #include int main() { std::string s= "n8Name4Surname"; std::vector parts; const char digits = "0123456789"; std::string::size_type from=0, to=std::string::npos; do { from = s. Find_first_of(digits, from); if (std::string::npos! = from) from = s.
Find_first_not_of(digits, from); if (std::string::npos! = from) { to = s. Find_first_of(digits, from); if (std::string::npos == to) parts.
Push_back(s. Substr(from)); else parts. Push_back(s.
Substr(from, to-from)); from = to; // could be npos } } while (std::string::npos! = from); for (int i=0; i.
Mandatory Boost Spirit sample: #include #include #include int main() { std::string s= "n8Name4Surname"; std::string::const_iterator b(s.begin()), e(s.end()); std::string ignore, name, surname; using namespace boost::spirit::qi; rule digit = char_("0123456789"), other = (char_ - digit); if (phrase_parse(b, e, *other >> +digit >> +other >> +digit >> +other, space, ignore, ignore, name, ignore, surname)) { std::cout.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.