Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. std::string stripnonalp(std::string input_string)
  2. {
  3.     std::string output_string = "";
  4.     bool lastwasspace = false;
  5.     for (char current_letter : input_string)
  6.     {
  7.         std::cout << "processing letter " << cu
  8.         current_letter = tolower(current_letter);
  9.  
  10.         if (lastwasspace == false)
  11.         {
  12.             if((current_letter==32) || (current_letter==13) || (current_letter==10))
  13.             {
  14.                 lastwasspace = true;
  15.                 output_string += " ";
  16.             }
  17.             if(current_letter==44)
  18.             {
  19.                 output_string+= "'";
  20.                 lastwasspace = false;
  21.             }
  22.             if((current_letter>='a') && (current_letter<='z'))
  23.             {
  24.                 output_string += current_letter;
  25.                 lastwasspace=false;
  26.             }
  27.  
  28.         }
  29.         else
  30.         {
  31.             if(current_letter==44)
  32.             {
  33.                 output_string+= "'";
  34.                 lastwasspace = false;
  35.             }
  36.             if((current_letter>='a') && (current_letter<='z'))
  37.             {
  38.                 output_string += current_letter;
  39.                 lastwasspace = false;
  40.             }
  41.  
  42.         }
  43.     }
  44.     return output_string;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement