Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std:: fix for regex example #8167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions examples/strings/regularExpressionExample/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ void ofApp::keyPressed(int _key){
}

string ofApp::grepStringInRegex(string _str, string _reg){
smatch match;
regex regEx(_reg, regex_constants::icase);
std::smatch match;
std::regex regEx(_reg, std::regex_constants::icase);

stringstream buffer;
while (regex_search(_str,match,regEx)) {
Expand All @@ -96,15 +96,15 @@ string ofApp::grepStringInRegex(string _str, string _reg){
}

int ofApp::countOccurencesInRegex(string _str, string _reg){
regex regEx(_reg, regex_constants::icase);
auto wordsBegin = sregex_iterator(_str.begin(), _str.end(), regEx);
auto wordsEnd = sregex_iterator();
std::regex regEx(_reg, std::regex_constants::icase);
auto wordsBegin = std::sregex_iterator(_str.begin(), _str.end(), regEx);
auto wordsEnd = std::sregex_iterator();
return distance(wordsBegin, wordsEnd);
};

bool ofApp::isKeyInRegex(int keyPressed, string _reg){
string typedKey(1, keyPressed);
regex regEx(_reg, regex_constants::icase);
std::regex regEx(_reg, std::regex_constants::icase);
if (regex_match(typedKey, regEx)) {
return true;
} else {
Expand All @@ -113,13 +113,13 @@ bool ofApp::isKeyInRegex(int keyPressed, string _reg){
}

vector<string> ofApp::matchesInRegex(string _str, string _reg){
regex regEx(_reg, regex_constants::icase);
std::regex regEx(_reg, std::regex_constants::icase);
vector<string> results;
auto wordsBegin = sregex_iterator(_str.begin(), _str.end(), regEx);
auto wordsEnd = sregex_iterator();
auto wordsBegin = std::sregex_iterator(_str.begin(), _str.end(), regEx);
auto wordsEnd = std::sregex_iterator();

for(std::sregex_iterator i = wordsBegin; i != wordsEnd; ++i){
smatch m = *i;
std::smatch m = *i;
results.push_back(m.str());
}
return results;
Expand Down