Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string StringUtils::filterStringByScope(const std::string &str, char cOpen, char cClose)
- {
- std::string result;
- unsigned countChar = 0;
- std::stack<char> stackChar;
- while (str[countChar] != cOpen)
- {
- ++countChar;
- if (countChar >= str.length())
- {
- return result;
- }
- }
- result = str[countChar];
- ++countChar;
- stackChar.push(cOpen);
- while(stackChar.size() > 0 && countChar < str.length())
- {
- result+= str[countChar];
- if (str[countChar] == cOpen) stackChar.push(cOpen);
- else if (str[countChar] == cClose) stackChar.pop();
- ++countChar;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement