fork(12) download
  1. #include <iostream>
  2. #include <dirent.h>
  3. #include <regex>
  4. #include <vector>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int main(void){
  10. vector<string> dir{".","..",".test","test.txt", "text" };
  11.  
  12. string rgs="^\\.";
  13. cout <<rgs<<endl;
  14. regex self_regex(rgs);
  15. for (auto &x:dir) {
  16. if (regex_search(x,self_regex)){
  17. cout << "matches regex" << x << endl;
  18. }
  19. else{
  20. cout << "does not match regex " << x << endl;
  21. }
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 3496KB
stdin
Standard input is empty
stdout
^\.
matches regex.
matches regex..
matches regex.test
does not match regex test.txt
does not match regex text