5 for (
const char& i : str)
16 for (std::size_t i = 0; i < str.length(); i++)
18 if (str[i] != find) ss << str[i];
25 std::string
StringTools::Replace(
const std::string& str,
const std::string& find,
const std::string& subst)
27 if (find.length() == 0)
return str;
31 std::size_t posFound = 0;
32 std::size_t lastFound = 0;
34 while (posFound != std::string::npos)
37 posFound = str.find(find, posFound);
39 if (posFound != std::string::npos)
41 ss << str.substr(lastFound, posFound - lastFound) << subst;
42 posFound += find.length();
46 ss << str.substr(lastFound, (str.length()) - lastFound);
56 if (str.length() == 0)
return false;
58 bool alreadyParsedDecimalPoint =
false;
59 std::size_t digitCount = 0;
61 for (std::size_t i = 0; i < str.length(); i++)
64 ((str[i] >=
'0') && (str[i] <=
'9')) ||
65 ((str[i] ==
'-') && (i == 0)) ||
66 ((str[i] ==
'.') && (allowDecimalPoint) && (!alreadyParsedDecimalPoint) && (digitCount > 0))
72 if (((str[i] >=
'0') && (str[i] <=
'9'))) digitCount++;
73 if (str[i] ==
'.') alreadyParsedDecimalPoint =
true;
77 return digitCount > 0;
82 bool isDecimal =
false;
84 if (str.length() == 0)
return false;
85 if (
Contains(str,
'.')) isDecimal =
true;
91 out_number = std::stold(str);
94 catch (std::invalid_argument&)
98 catch (std::out_of_range&)
107 out_number = (
long double)std::stoll(str);
110 catch (std::invalid_argument&)
114 catch (std::out_of_range&)
125 if (str.length() == 0)
return std::vector<std::string>();
132 if (str.length() == 0)
return std::vector<std::string>();
134 std::vector<std::string> parts;
136 if (delimiter.length() == 0)
138 for (std::size_t i = 0; i < str.length(); i++)
140 parts.push_back(std::string({ str[i] }));
145 std::size_t posFound = 0;
146 std::size_t lastFound = 0;
148 while (posFound != std::string::npos)
150 lastFound = posFound;
151 posFound = str.find(delimiter, posFound);
155 if (posFound != std::string::npos)
157 found = str.substr(lastFound, posFound - lastFound);
158 posFound += delimiter.length();
162 found = str.substr(lastFound, str.length() - lastFound);
165 parts.push_back(found);
173 std::stringstream ss;
174 for (std::size_t i = 0; i < str.length(); i++)
176 if ((str[i] >=
'A') && (str[i] <=
'Z')) ss << (char)(((
int)str[i]) + 32);
177 else if (str[i] == -60) ss << (char)-28;
178 else if (str[i] == -42) ss << (char)-10;
179 else if (str[i] == -36) ss << (char)-4;