Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Change double spaces in text to single spaces.
- #include <iostream>
- #include <string>
- #include <regex>
- using namespace std;
- int main()
- {
- string text("All double spaces in this text should be single spaces.");
- regex two_spaces(" "); // This is double space, the pattern we want to fix.
- cout << text << '\n'; // Show text to fix.
- cout << "\nFixing double spaces ...\n";
- // Replace all double spaces with a single space.
- string better_text = regex_replace(text, two_spaces, " ");
- cout << "\nText is fixed:\n";
- cout << better_text << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement