vector LoadMatrixes(string FileName) { int counter = 0; ifstream f(FileName); string line, temp; regex squareBracketsRegex("\\[([^\\]\\[]+)\\]"); regex matrixRegex("(\\d+.\\d+)+"); while (getline(f, line)) { if (line[0] == 'M' || line[0] == '-') { //end of matrix cout << "----------------" << endl; //regex search and append to vector of matrix // "\[([^\]\[]+)\]" -> [...] // "(\d+.\d+)+" if (temp.length() > 0) { for (smatch m; regex_search(temp, m, squareBracketsRegex); temp = m.suffix()) { //cout << m[1] << endl; //Find each number string row = m[1].str(); for (smatch n; regex_search(row, n, matrixRegex); row = n.suffix()) { cout << n[1] << ", "; } cout << endl; } //clear temp temp = ""; } } else { //Add line for regex temp += line; } //Debug line if (bDebug) { cout << "| " << counter << " | "; if (counter % 8 == 0 && counter != 0) { cout << endl; } counter++; } } return matrixes; }