#include <iostream>
#include <regex>
#include <string>
int main()
{
  std::string myString("abcdefg");
  std::regex  myRegex ("cde"    );
  std::smatch myMatches;
  std::regex_search(myString, myMatches, myRegex);
  if (myMatches.size() > 0) std::cout << myMatches[0] << std::endl;
  
  return 0;
}
// Output: cde
Reference: http://www.cplusplus.com/reference/regex/regex_search/
Tuesday, August 29, 2017
C++11: Regex
Regular Expressions (Regex) were added to C++11. Here is an example:
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment