Skip to content

Commit b691e6b

Browse files
authored
std:: fix for regex example (#8167)
#changelog #examples
1 parent 0e4d63d commit b691e6b

File tree

1 file changed

+10
-10
lines changed
  • examples/strings/regularExpressionExample/src

1 file changed

+10
-10
lines changed

examples/strings/regularExpressionExample/src/ofApp.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ void ofApp::keyPressed(int _key){
8282
}
8383

8484
string ofApp::grepStringInRegex(string _str, string _reg){
85-
smatch match;
86-
regex regEx(_reg, regex_constants::icase);
85+
std::smatch match;
86+
std::regex regEx(_reg, std::regex_constants::icase);
8787

8888
stringstream buffer;
8989
while (regex_search(_str,match,regEx)) {
@@ -96,15 +96,15 @@ string ofApp::grepStringInRegex(string _str, string _reg){
9696
}
9797

9898
int ofApp::countOccurencesInRegex(string _str, string _reg){
99-
regex regEx(_reg, regex_constants::icase);
100-
auto wordsBegin = sregex_iterator(_str.begin(), _str.end(), regEx);
101-
auto wordsEnd = sregex_iterator();
99+
std::regex regEx(_reg, std::regex_constants::icase);
100+
auto wordsBegin = std::sregex_iterator(_str.begin(), _str.end(), regEx);
101+
auto wordsEnd = std::sregex_iterator();
102102
return distance(wordsBegin, wordsEnd);
103103
};
104104

105105
bool ofApp::isKeyInRegex(int keyPressed, string _reg){
106106
string typedKey(1, keyPressed);
107-
regex regEx(_reg, regex_constants::icase);
107+
std::regex regEx(_reg, std::regex_constants::icase);
108108
if (regex_match(typedKey, regEx)) {
109109
return true;
110110
} else {
@@ -113,13 +113,13 @@ bool ofApp::isKeyInRegex(int keyPressed, string _reg){
113113
}
114114

115115
vector<string> ofApp::matchesInRegex(string _str, string _reg){
116-
regex regEx(_reg, regex_constants::icase);
116+
std::regex regEx(_reg, std::regex_constants::icase);
117117
vector<string> results;
118-
auto wordsBegin = sregex_iterator(_str.begin(), _str.end(), regEx);
119-
auto wordsEnd = sregex_iterator();
118+
auto wordsBegin = std::sregex_iterator(_str.begin(), _str.end(), regEx);
119+
auto wordsEnd = std::sregex_iterator();
120120

121121
for(std::sregex_iterator i = wordsBegin; i != wordsEnd; ++i){
122-
smatch m = *i;
122+
std::smatch m = *i;
123123
results.push_back(m.str());
124124
}
125125
return results;

0 commit comments

Comments
 (0)