Skip to content
Snippets Groups Projects
Commit 20427718 authored by Andreas Blakli's avatar Andreas Blakli
Browse files

La til splittStreng funksjon i HjelpeFunksjoner klassen, i filene...

La til splittStreng funksjon i HjelpeFunksjoner klassen, i filene hjelpefunksjoner.cpp og hjelpefunksjoner.h.
parent ace99fd8
No related branches found
No related tags found
No related merge requests found
......@@ -15,12 +15,18 @@ string HjelpeFunksjoner::rensStreng(const string str) {
// eller en ny regex replace som gjort ovenfor.
for (const char& c : rensetStreng) { // todo sjekk om problemer med char æøå i c.
tmp.push_back(c);
if (tmp == "Æ") tmp = "AE";
else if (tmp == "Ø") tmp = "O";
else if (tmp == "Å") tmp = "AA";
else if (tmp == "æ") tmp = "ae";
else if (tmp == "ø") tmp = "o";
else if (tmp == "å") tmp = "aa";
if (tmp == "Æ")
tmp = "AE";
else if (tmp == "Ø")
tmp = "O";
else if (tmp == "Å")
tmp = "AA";
else if (tmp == "æ")
tmp = "ae";
else if (tmp == "ø")
tmp = "o";
else if (tmp == "å")
tmp = "aa";
tmp2 += tmp;
tmp.clear();
}
......@@ -43,7 +49,8 @@ bool HjelpeFunksjoner::erBokstav(const string str) {
[](const char& val) { return isalpha(val) == true; });
if (it == str.end()) {
// cout << "\nTrue " << str << '\n';
return true;}
return true;
}
// cout << "\nfalse " << str << '\n';
return false;
}
......@@ -55,3 +62,16 @@ string HjelpeFunksjoner::gjorOmTilStorBokstav(const string str) {
}
return tmp;
}
vector<string> HjelpeFunksjoner::splittStreng(const char& splittPa, const string& str) {
vector<string> split;
string tmp = "";
for (const auto& val : str) {
if (val == splittPa) {
split.push_back(tmp);
tmp = "";
} else
tmp += val;
}
return split;
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ class HjelpeFunksjoner {
bool sjekkForUlovligTegn(std::string str);
bool erBokstav(std::string str);
std::string gjorOmTilStorBokstav(std::string str);
std::vector<std::string> splittStreng(const char & splittPa, const std::string & str);
};
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment