string s = "a,b, c ,,e,f,";
vector <string> fields;
boost::split( fields, s, "," );
print( fields );
This is given me this error:
Description Resource Path Location Type
‘__pred’ cannot be used as a function teste3 line 222, external location: /usr/include/c++/4.4/bits/stl_algo.h C/C++ Problem
And this give me the error:
Description Resource Path Location Type
Invalid arguments '
Candidates are:#0 & split(#0 &, #1 &, #2, enum boost::algorithm::token_compress_mode_type)
' Switch.cc /teste3 line 82 Semantic Error
Can someone advise me of what I'm doing wrong in this two examples.
I think split will not do what I want, because, I want to see if the number 8 in string src repeat it self more than 2 times an if so I have to return a 0; I'm thinking in regex...
Can someone advise me?
boost::algorithm::split_regex(SplitVec, src, boost::regex("8"));
but it gives me error
undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
I also test with:
boost::algorithm::split_regex(SplitVec, src, boost::algorithm::regex("8"));
But it gives me erro:
‘regex’ is not a member of ‘boost::algorithm’
I load the other libraries:
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/regex.hpp>
#include <boost/regex.hpp>
I want to see if the number 8 in string src repeat it self more than 2 times an if so I have to return a 0; I'm thinking in regex
In that case you don't need to split the string, and you don't need a regular expression either. Either you're checking if std::count(str.begin(), str.end(), '8') > 2 or you're checking if str.find("888") != std::string::npos, depending on whether it's any 2+ numbers 8 or 2+ adjacent 8s.
Ok thanks, but I think that will not work for me because I have to put the id_equip that is a string instead of the '8' because the id_equip will have a get method that will collect random numbers.
If you have some other tip I will be glade to know.
std::string src = ttmsg->getSource(); // the string src have a lot of numbers like +8-23+7-5+67-123+90-321+8- and so on... is big, the signal + and - separate the ID that I want from the others that I do not want.
and I have other string with the module Id:
std::string teste;
std::stringstream teste_aux;
teste_aux << getId();
teste = teste_aux.str();// the string teste have the Id of my module that is also a number.
id_teste = "+" + teste + "-"; // to the integer I add the signal + and -
How can I search in string src if the Id of my module, that i have put between signal + and - and that is in string id_teste, repeats more than two times in string src.
Can someone please advise me?
Sorry for not being so detailed at first but I was thinking at first that the split function will be my solution.