Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include "tiedostonluku.hh"
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. bool lue_tehtavatiedosto(ifstream& virta){
  9.     regex reg(
  10.                 "[[:space:]]*"
  11.                 "([[:alpha:]_]+)"
  12.                 "[[:space:]]*"
  13.                 ":"
  14.                 "[[:space:]]*"
  15.                 "([[:alpha:]_]+)"
  16.                 "[[:space:]]*"
  17.     );
  18.     smatch tulos;
  19.     string rivi;
  20.  
  21.     if  (not getline(virta, rivi)){
  22.         return true;
  23.     }
  24.  
  25.     else{
  26.         if ( regex_match(rivi, tulos, reg) ){
  27.             return true;
  28.         }
  29.  
  30.         else {
  31.             return false;
  32.         }
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement