| 145 | |
| 146 | |
| 147 | void separateStringIntoCoeffAndPaulis(string line, string &coeff, string &paulis) { |
| 148 | |
| 149 | // absolutely gauranteed to match due to prior matching of regexes::line |
| 150 | smatch match; |
| 151 | |
| 152 | // locate the coefficient |
| 153 | regex_search(line, match, regexes::num); |
| 154 | coeff = match.str(0); |
| 155 | |
| 156 | // the remainder of the line must be the paulis, but we explicitly match to |
| 157 | // regex just in case we later permit additional substrings like comments. |
| 158 | // we must match only the substring AFTER the coeff, since valid coeffs (e.g. |
| 159 | // 1) can be mistaken for a Pauli code. |
| 160 | line = line.substr(match.position(0) + match.length(0)); |
| 161 | regex_search(line, match, regexes::paulis); |
| 162 | paulis = match.str(0); |
| 163 | } |
| 164 | |
| 165 | |
| 166 | int getNumPaulisInLine(string line) { |
no outgoing calls
no test coverage detected