diff options
| author | Leonetienne <leon@etiennes.de> | 2022-04-09 14:59:57 +0200 |
|---|---|---|
| committer | Leonetienne <leon@etiennes.de> | 2022-04-09 15:05:31 +0200 |
| commit | 3b33447103f72dbca93a370423ff3592e18cfddb (patch) | |
| tree | 59a955e0e36b66b678ad82c5bf50d1fe1f72dda7 | |
| parent | 577bc93d6d2fa2645a121c7c454248d8a663a8b6 (diff) | |
Added ruwe to repwace R lettews witw W
| -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; |
