Skip to content

Instantly share code, notes, and snippets.

@xdanielsb
Created March 5, 2021 10:30
Show Gist options
  • Select an option

  • Save xdanielsb/aa8da6de3ba26712c6a002601a3d1fa1 to your computer and use it in GitHub Desktop.

Select an option

Save xdanielsb/aa8da6de3ba26712c6a002601a3d1fa1 to your computer and use it in GitHub Desktop.

Revisions

  1. xdanielsb created this gist Mar 5, 2021.
    20 changes: 20 additions & 0 deletions regex timestamp log server
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #include<bits/stdc++.h>
    using namespace std;
    /*
    * @author: xdanielsb
    * get timestamps log file
    */
    int main(){
    ifstream file("redh324-p.log");
    string str;
    smatch m;
    regex regexp("[0-9]{2}/[a-zA-z]{3}/[0-9]{4}:[0-9]{2}:[0-9]{2}:[0-9]{2}");
    set<string> aux;
    while (getline(file, str)){
    regex_search(str, m, regexp);
    for (auto x : m) aux.insert(x);
    }
    for( string x: aux){
    cout << x <<endl;
    }
    }