Fixed regex! Much simpler and sensible implementation too.

This commit is contained in:
Nathan Braswell
2014-01-07 21:31:56 -05:00
parent 0297f29dcd
commit 0d47a03986
6 changed files with 92 additions and 167 deletions

View File

@@ -40,3 +40,15 @@ std::string strSlice(std::string str, int begin, int end) {
end += str.length()+1;
return str.substr(begin, end-begin);
}
int findPerenEnd(std::string str, int i) {
int numHangingOpen = 0;
for (; i< str.length(); i++) {
if (str[i] == '(')
numHangingOpen++;
else if (str[i] == ')')
numHangingOpen--;
if (numHangingOpen == 0)
return i;
}
}