17 using std::regex_match;
18 using std::regex_replace;
22 using std::string_view;
33 const string StringTools::replace(
const string& str,
const char what,
const char by, int64_t beginIndex) {
35 std::replace(result.begin() + beginIndex, result.end(), what, by);
39 const string StringTools::replace(
const string& str,
const string& what,
const string& by, int64_t beginIndex) {
41 if (what.empty())
return result;
42 while ((beginIndex = result.find(what, beginIndex)) != std::string::npos) {
43 result.replace(beginIndex, what.length(), by);
44 beginIndex += by.length();
50 string stringA = string1;
51 string stringB = string2;
52 transform(stringA.begin(), stringA.end(), stringA.begin(), (
int(*)(
int))toupper);
53 transform(stringB.begin(), stringB.end(), stringB.begin(), (
int(*)(
int))toupper);
54 return stringA == stringB;
65 return isspace(c) == 0;
74 return isspace(c) == 0;
84 for (int64_t i = 0; i < str.size(); i++) {
85 if (isspace(str[i]) != 0) start++;
else break;
88 for (int64_t i = str.size() - 1; i >= 0; i--) {
89 if (isspace(str[i]) != 0) end++;
else break;
91 return string_view(&str[start], str.size() - (start + end));
96 transform(result.begin(), result.end(), result.begin(), (
int(*)(
int))tolower);
102 transform(result.begin(), result.end(), result.begin(), (
int(*)(
int))toupper);
107 if (matches ==
nullptr) {
108 return regex_match(str, regex(pattern, std::regex::ECMAScript));
110 return regex_match(str, *matches, regex(pattern, std::regex::ECMAScript));
115 if (matches ==
nullptr) {
116 return regex_search(str, regex(pattern, std::regex::ECMAScript));
118 return regex_search(str, *matches, regex(pattern, std::regex::ECMAScript));
123 return regex_replace(str, regex(pattern, std::regex::ECMAScript), by);
128 t.
tokenize(str, delimiters, emptyTokens);
143 return u8It.
hasNext() ==
true?::Character::toString(u8It.
next()):string();
const vector< string > & getTokens()
void tokenize(const string &str, const string &delimiters, bool emptyTokens=false)
Tokenize.
UTF8 string character iterator.
int64_t getBinaryPosition() const
int64_t getCharacterPosition() const
void seekCharacterPosition(int64_t position) const
Seek character position.