Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <85>login[2775]: ROOT LOGIN on '/dev/tty1'
  2.  
  3. QRegExp re1_1(".*: (?<username>.*) LOGIN.*");
  4. foreach(const QString& str, strings)
  5. {
  6. if(re1_1.exactMatch(str))
  7. qDebug() << "Found: " << ":" << str;
  8. }
  9.  
  10. .*:s+(.*)s+LOGIN.*
  11.  
  12. QString source{"<85>login[2775]: ROOT LOGIN on '/dev/tty1'"};
  13. QRegExp regexp{R"-(.*:s+(.*)s+LOGIN.*)-"};
  14. if(regexp.exactMatch(source))
  15. qDebug() << "The found login is: " << regexp.cap(1);
  16.  
  17. QString source{"<85>login[2775]: ROOT LOGIN on '/dev/tty1'"};
  18. QRegularExpression regexp{R"-(.*?:s+(.*?)s+LOGIN.*)-"};
  19. QRegularExpressionMatch match = regexp.match(source);
  20. if(match.hasMatch())
  21. qDebug() << "The found login is: " << match.captured(1);
  22.  
  23. std::string s ("<85>login[2775]: ROOT LOGIN on '/dev/tty1'");
  24. std::regex e (".*:\s+(.*?)\s+LOGIN.*");
  25. std::smatch m;
  26. if(std::regex_search (s,m,e)) std::cout << m[1];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement