1
1
#include < iostream>
2
2
#include < random>
3
+ #include < regex>
4
+
5
+
6
+ std::wstring regexReplace (std::wstring str, std::wregex regex, std::wstring search, std::wstring replace) {
7
+ std::wsmatch m;
8
+ std::wstring out;
9
+ std::wstring in = str;
10
+ while (std::regex_search (in, m, regex)) {
11
+ out += m.prefix ();
12
+ std::wregex re (search);
13
+ out += std::regex_replace (m[0 ].str (), re, replace);
14
+ in = m.suffix ();
15
+ }
16
+ return out += in;
17
+ }
3
18
4
19
// Very bad code
5
20
std::wstring owoify (std::wstring STR) {
@@ -9,33 +24,38 @@ std::wstring owoify(std::wstring STR) {
9
24
const wchar_t *prefix[] = {
10
25
L" OWO" , L" OwO" , L" 0w0" , L" < 3" , L" UwU" , L" HIIII!" , L" H - hewwo??" , L" Huohhhh."
11
26
};
12
- std::uniform_int_distribution<int > pr (0 , 8 );
27
+ std::uniform_int_distribution<int > pr (0 , 7 );
13
28
std::wstring px = prefix[pr (e1 )];
14
29
15
30
const wchar_t *suffix[] = {
16
31
L" ..," , L" fwendo" , L" Huoh." , L" ._." , L" ;-;" , L" ;_;" , L" (;ω;)" , L" ÙωÙ" , L" UwU" , L" (人◕ω◕)" , L" (●´ω`●)" , L" (✿ ♡‿♡)" ,
17
32
L" (◠‿◠✿)" , L" ^ - ^" , L" ^ _ ^" , L" > _ <" , L" > _ >" , L" :P" , L" :3" , L" ;3" , L" x3" , L" :D" , L" xD" , L" XDDD" , L" (^v^)" ,
18
33
L" ㅇㅅㅇ" , L" (• o •)" , L" ʕ•̫͡•ʔ" , L" ʕʘ‿ʘʔ" , L" ( '◟ ')"
19
34
};
20
- std::uniform_int_distribution<int > sr (0 , 30 );
35
+ std::uniform_int_distribution<int > sr (0 , 29 );
21
36
std::wstring sx = suffix[sr (e1 )];
22
37
23
- if (RSTR.find (L" r" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" r" )) != std::string::npos) { RSTR.replace (pos, 1 , L" w" ); } }
24
- if (RSTR.find (L" l" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" l" )) != std::string::npos) { RSTR.replace (pos, 1 , L" w" ); } }
25
- if (RSTR.find (L" R" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" R" )) != std::string::npos) { RSTR.replace (pos, 1 , L" W" ); } }
26
- if (RSTR.find (L" L" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" L" )) != std::string::npos) { RSTR.replace (pos, 1 , L" W" ); } }
27
- if (RSTR.find (L" no" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" no" )) != std::string::npos) { RSTR.replace (pos, 2 , L" nu" ); } }
28
- if (RSTR.find (L" have" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" have" )) != std::string::npos) { RSTR.replace (pos, 4 , L" haz" ); } }
29
- if (RSTR.find (L" has" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" has" )) != std::string::npos) { RSTR.replace (pos, 3 , L" haz" ); } }
30
- if (RSTR.find (L" you" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" you" )) != std::string::npos) { RSTR.replace (pos, 3 , L" uu" ); } }
31
- if (RSTR.find (L" the" ) != std::string::npos) { size_t pos; while ((pos = RSTR.find (L" the" )) != std::string::npos) { RSTR.replace (pos, 3 , L" da" ); } }
32
-
38
+ RSTR = std::regex_replace (RSTR, std::wregex (L" r" ), L" w" );
39
+ RSTR = std::regex_replace (RSTR, std::wregex (L" l" ), L" w" );
40
+ RSTR = std::regex_replace (RSTR, std::wregex (L" R" ), L" W" );
41
+ RSTR = std::regex_replace (RSTR, std::wregex (L" L" ), L" W" );
42
+ RSTR = std::regex_replace (RSTR, std::wregex (L" ha(ve|s)" , std::regex_constants::icase), L" haz" );
43
+ RSTR = regexReplace (RSTR, std::wregex (L" n[o]+" , std::regex_constants::icase), L" o" , L" u" );
44
+ RSTR = std::regex_replace (RSTR, std::wregex (L" your" , std::regex_constants::icase), L" ur" );
45
+ RSTR = std::regex_replace (RSTR, std::wregex (L" you" , std::regex_constants::icase), L" uu" );
46
+ RSTR = std::regex_replace (RSTR, std::wregex (L" the" , std::regex_constants::icase), L" da" );
47
+ RSTR = std::regex_replace (RSTR, std::wregex (L" with" , std::regex_constants::icase), L" wif" );
48
+ RSTR = std::regex_replace (RSTR, std::wregex (L" :D" , std::regex_constants::icase), L" UwU" );
49
+ RSTR = std::regex_replace (RSTR, std::wregex (L" :o" , std::regex_constants::icase), L" owo" );
50
+ RSTR = std::regex_replace (RSTR, std::wregex (L" :O" , std::regex_constants::icase), L" OwO" );
51
+ RSTR = std::regex_replace (RSTR, std::wregex (L" :\\\\ " , std::regex_constants::icase), L" :3" );
52
+
33
53
std::wstring space = L" " ;
34
54
return px + space + RSTR + space + sx;
35
55
}
36
56
37
57
using namespace std ;
38
- int main ()
58
+ int wmain ()
39
59
{
40
60
const wchar_t string[] = L" String to owoify" ;
41
61
wcout << owoify (string);
0 commit comments