#include <iostream>
#include <sstream>
#include <string>
#include <vector>

std::string s1 = "[1 -2.5 3;4 5.25 6;7 8 9.12]";

std::string cutter(std::string &s){
    std::string res = "";
    for (auto c : s)                                 // Loop over all chars in s
    {
        if (c == ';') res += ' ';                    // Replace ; with space
        else if ((c != '[') && (c != ']')) res += c; // Skip [ and ]
    }
    return res;
}

std::vector<float> string_to_floats(std::string &s)
{
      float f;
      std::vector<float> res;

      std::stringstream stream(s);        // Create and initialize the stream
      while(1)
      {
          stream >> f;                    // Try to read a float
          if (stream.fail()) return res;  // If it failed, return the result
          res.push_back(f);               // Save the float
      }
}

int main()
{
    std::string s2 = cutter(s1);
    std::cout << s2 << std::endl;

    std::vector<float> values = string_to_floats(s2);
    std::cout << "Number of floats: " << values.size() << std::endl;
    for (auto f : values) std::cout << f << std::endl;

    return 0;
}