w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
qt regex to boost regex conversion for taking number from inside a string

I've resolved.

I've taken inspiration from this post and I've changed method implementation, not the regex:

float Importer::getNumberFromString(const std::string
&sString)
{
  float fElevation = 0.0f;
  boost::regex e("(-?\d+(?:[\.,]\d+(?:e\d+)?)?)");
  boost::sregex_iterator it(sString.begin(), sString.end(), e);
  boost::sregex_iterator end;
  if (it != end)
  {
    std::string sValue(it->str());
    boost::spirit::qi::parse(sValue.begin(), sValue.end(), fElevation);
  }
  return fElevation;
}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.