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.
Get timespams log file
#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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment