diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Src/LibUwu.h | 40 |
2 files changed, 41 insertions, 1 deletions
@@ -37,7 +37,7 @@ # *.ipr
# CMake
-cmake-build-*/
+build*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
diff --git a/Src/LibUwu.h b/Src/LibUwu.h index b1e0cf0..bdf9b0f 100644 --- a/Src/LibUwu.h +++ b/Src/LibUwu.h @@ -196,6 +196,46 @@ static inline std::string MakeUwu(std::string boringString) { } ); + // Replace R with W, but only (if it's preceeded by a vowel, + // or preceeded by another 'r', + // or if it's the first character of a word) + // and if it's not the last character of a word + boringString = Util::ConditionalReplaceButKeepSigns( + boringString, + "r", + "w", + [](const std::string& original, const std::string& finding, const std::size_t index) { + // Don't replace if it's the last character + if (index + finding.length() == original.length()) + return false; + + // Do blindly replace if it's the first character + if (index == 0) + return true; + + // Fetch the last character + const char lastChar = CharTools::MakeLower(original[index - 1]); + + // Fetch the next char + const char nextChar = CharTools::MakeLower(original[index + finding.length()]); + + // Don't replace, if the last char is not a letter + if (!CharTools::IsLetter(lastChar)) + return false; + + // Don't replace, if the next char is not a letter + if (!CharTools::IsLetter(nextChar)) + return false; + + // Replace, if the last character is an 'r' aswell + if (lastChar == 'r') + return true; + + // Replace, if the last character is a vowel. + return CharTools::IsVowel(lastChar); + } + ); + // Replace random punctuation with uwwwwu cute symbols // About evewy fifteenth symbol std::stringstream ss; |
