Last active
          January 27, 2019 15:54 
        
      - 
      
- 
        Save oakaigh/47e672d2e50c63d78e87f0089cf315bb to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <algorithm> | |
| #include <iostream> | |
| #include <cctype> | |
| #include <regex> | |
| int main() | |
| { | |
| std::string str("server\t\n{ a = 5; b ={ a } c = what; } \nisthatthe{ case; }"); | |
| //str.erase(remove_if(str.begin(), str.end(), isspace), str.end()); | |
| std::regex expr("([^]+?)\\{([^]+?)\\}"); | |
| std::smatch matches; | |
| for (std::sregex_iterator it(str.begin(), str.end(), expr), end_it; it != end_it; it++) { | |
| std::cout << ">>>>>> START <<<<<<<" << std::endl; | |
| std::cout << it->str() << std::endl; | |
| std::cout << ">>>>>> END <<<<<<<" << std::endl; | |
| } | |
| /*if (std::regex_search(str, matches, expr)) { | |
| for (size_t i = 1; i < matches.size(); i++) { | |
| std::string match(matches[i].first, matches[i].second); | |
| std::cout << "matches[" << i << "] = " << match << std::endl; | |
| } | |
| }*/ | |
| return 0; | |
| } | 
      
      
  Author
  
  
        
      
            oakaigh
  
      
      
      commented 
        Jan 27, 2019 
      
    
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment