Advertisement
neogz

regexi

Feb 9th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>  
  3. #include <vector>
  4. #include <algorithm>
  5. #include <regex>
  6. using namespace std;
  7. int main(){
  8.     //(?=.)
  9.     //string brojevi    = "(?=.*[0-9])";
  10.     //string mslova     = "(?=.*[a-z])";
  11.     //string vslova     = "(?=.*[A-Z])";
  12.     //string specijalni = "(?=.*[@#$%])";
  13.     //string minimalno  = "(?=.{7,})";
  14.  
  15.     //string pravilo = mslova + vslova + brojevi + specijalni+ minimalno;
  16.  
  17.     //telefonski broj
  18.     // +387 (33) 222 333
  19.     //string unos;
  20.     //string pravilo = "(\\+)?([0-9]{3})(\\()?([0-9]{2})(\\))?([- ])?([0-9]{3})([- ])?([0-9]{3})";
  21.  
  22.  
  23.     //(\\d{2})
  24.  
  25.     string ime;
  26.     string prezime;
  27.     string password;
  28.        
  29.     string brojevi      = "(?=.*[0-9])";
  30.     string mslova       = "(?=.*[a-z])";
  31.     string vslova       = "(?=.*[A-Z])";
  32.     string specijalni   = "(?=.*[@#$%*]{1,})";
  33.     string minimalno    = "(?=.{7,})";
  34.  
  35.  
  36.     cout << "     ime: ";
  37.     getline(cin, ime);
  38.  
  39.     cout << " prezime: ";
  40.     getline(cin, prezime);
  41.  
  42.  
  43.     do{
  44.  
  45.    
  46.         cout << "password: ";
  47.         getline(cin, password);
  48.  
  49.         string pravilo = brojevi + mslova + vslova + specijalni + minimalno;
  50.  
  51.         if (regex_search(password, regex(pravilo))){
  52.             pravilo = "(?:(" + ime + "|" + prezime + "))";
  53.             if (!regex_search(password, regex(pravilo))){
  54.                 cout << "     OK     " << endl;
  55.             }
  56.         }
  57.         cout << "---------------------------------------\n";
  58.     } while (password!="exit");
  59.    
  60.  
  61.    
  62.    
  63.     system("pause > null");
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement