Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string stripnonalp(std::string input_string)
- {
- std::string output_string = "";
- bool lastwasspace = 0;
- for (char current_letter : input_string)
- {
- current_letter = tolower(current_letter);
- if (lastwasspace == false)
- {
- if((current_letter == ' ') || (current_letter == '\n') || (current_letter == '\r'))
- {
- lastwasspace = true;
- output_string += " ";
- }
- if(current_letter == '\'')
- output_string += "'";
- if((current_letter >= 'a') && (current_letter <= 'z'))
- output_string += current_letter;
- }
- if (lastwasspace == true)
- {
- if(current_letter == '\'')
- {
- output_string += "'";
- lastwasspace = false;
- }
- if((current_letter >= 'a') && (current_letter <= 'z'))
- {
- output_string += current_letter;
- lastwasspace = false;
- }
- }
- }
- return output_string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement