Guest User

Untitled

a guest
Apr 16th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1.     //test string
  2.     std::string str = "a9382a_ao-EATSHITANDDIE_-_--__-";
  3.     //go through each character in the string
  4.     for(int i = 0; i < str.length(); i++)
  5.     {
  6.         char c = str[i];
  7.         //if the character doesn't equal '_' or '-'
  8.         if(!(c == '_' || c == '-'))
  9.         {
  10.             //check for numbers
  11.             if(c >= '0' && c <= '9')
  12.                 continue;
  13.             //check for upper-case letters
  14.             if(c >= 'A' && c <= 'Z')
  15.                 continue;
  16.             //check for lower-case
  17.             if(c >= 'a' && c <= 'z')
  18.                 continue;
  19.             //if it gets here, it is neither an alpha character or a number character,
  20.             //and it isn't one of the two exempt characters, so we replace it with a space
  21.             str[i] = ' ';
  22.         }
  23.     }
Add Comment
Please, Sign In to add comment