15 using std::regex_match;
16 using std::regex_replace;
19 using std::string_view;
27 const string StringTools::replace(
const string& src,
const char what,
const char by,
int beginIndex) {
29 std::replace(result.begin() + beginIndex, result.end(), what, by);
33 const string StringTools::replace(
const string& src,
const string& what,
const string& by,
int beginIndex) {
35 if (what.empty())
return result;
36 while ((beginIndex = result.find(what, beginIndex)) != std::string::npos) {
37 result.replace(beginIndex, what.length(), by);
38 beginIndex += by.length();
44 string stringA = string1;
45 string stringB = string2;
46 transform(stringA.begin(), stringA.end(), stringA.begin(), (
int(*)(
int))toupper);
47 transform(stringB.begin(), stringB.end(), stringB.begin(), (
int(*)(
int))toupper);
48 return stringA == stringB;
59 return isspace(c) == 0;
68 return isspace(c) == 0;
78 for (
auto i = 0; i < src.size(); i++) {
79 if (isspace(src[i]) != 0) start++;
else break;
82 for (
int i = src.size() - 1; i >= 0; i--) {
83 if (isspace(src[i]) != 0) end++;
else break;
85 return string_view(&src[start], src.size() - start - end);
90 transform(result.begin(), result.end(), result.begin(), (
int(*)(
int))tolower);
96 transform(result.begin(), result.end(), result.begin(), (
int(*)(
int))toupper);
102 return regex_match(src, regex(pattern));
107 return regex_search(src, regex(pattern, std::regex::ECMAScript));
111 return regex_replace(src, regex(pattern, std::regex::ECMAScript), by);
116 t.
tokenize(str, delimiters, emptyTokens);
const vector< string > & getTokens()
void tokenize(const string &str, const string &delimiters, bool emptyTokens=false)
Tokenize.