13 using std::string_view;
29 inline static const bool startsWith(
const string& str,
const string& prefix) {
30 return str.find(prefix) == 0;
39 inline static const bool viewStartsWith(
const string_view& str,
const string_view& prefix) {
40 return str.find(prefix) == 0;
49 inline static const bool endsWith(
const string& str,
const string& suffix) {
51 str.size() >= suffix.size() &&
52 str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
61 inline static const bool viewEndsWith(
const string_view& str,
const string_view& suffix) {
63 str.size() >= suffix.size() &&
64 str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
75 static const string replace(
const string& str,
const char what,
const char by, int64_t beginIndex = 0);
85 static const string replace(
const string& str,
const string& what,
const string& by, int64_t beginIndex = 0);
94 inline static int64_t
indexOf(
const string& str,
char what, int64_t beginIndex = 0) {
95 return str.find(what, beginIndex);
105 inline static int64_t
indexOf(
const string& str,
const string& what, int64_t beginIndex = 0) {
106 return str.find(what, beginIndex);
116 inline static int64_t
firstIndexOf(
const string& str,
char what, int64_t beginIndex = 0) {
117 return indexOf(str, what, beginIndex);
127 inline static int64_t
firstIndexOf(
const string& str,
const string& what, int64_t beginIndex = 0) {
128 return indexOf(str, what, beginIndex);
138 inline static int64_t
lastIndexOf(
const string& str,
const char what, int64_t endIndex = string::npos) {
139 return str.rfind(what, endIndex);
149 inline static int64_t
lastIndexOf(
const string& str,
const string& what, int64_t endIndex = string::npos) {
150 return str.rfind(what, endIndex);
160 inline static int64_t
firstIndexOfChar(
const string& str,
char what, int64_t beginIndex = 0) {
161 return str.find_first_of(what, beginIndex);
171 inline static int64_t
firstIndexOfChars(
const string& str,
const string& what, int64_t beginIndex = 0) {
172 return str.find_first_of(what, beginIndex);
182 inline static int64_t
lastIndexOfChar(
const string& str,
char what, int64_t endIndex = string::npos) {
183 return str.find_last_of(what, endIndex);
193 inline static int64_t
lastIndexOfChars(
const string& str,
const string& what, int64_t endIndex = string::npos) {
194 return str.find_last_of(what, endIndex);
203 inline static const string substring(
const string& str, int64_t beginIndex) {
204 return str.substr(beginIndex);
213 inline static const string_view
viewSubstring(
const string_view& str, int64_t beginIndex) {
214 return str.substr(beginIndex);
224 inline static const string substring(
const string& str, int64_t beginIndex, int64_t endIndex) {
225 return str.substr(beginIndex, endIndex - beginIndex);
235 inline static const string_view
viewSubstring(
const string_view& str, int64_t beginIndex, int64_t endIndex) {
236 return str.substr(beginIndex, endIndex - beginIndex);
252 static const string trim(
const string& str);
259 static const string_view
viewTrim(
const string_view& str);
266 static const string toLowerCase(
const string& str);
273 static const string toUpperCase(
const string& str);
282 static bool regexMatch(
const string& str,
const string& pattern, smatch* matches =
nullptr);
291 static bool regexSearch(
const string& str,
const string& pattern, smatch* matches =
nullptr);
300 static const string regexReplace(
const string& str,
const string& pattern,
const string& by);
309 static const vector<string>
tokenize(
const string& str,
const string& delimiters,
bool emptyTokens =
false);
318 inline static const string padLeft(
const string& str,
const string& by, int64_t toSize) {
320 while (result.size() < toSize) result = by + result;
331 inline static const string padRight(
const string& str,
const string& by, int64_t toSize) {
333 while (result.size() < toSize) result = result + by;
344 inline static const string indent(
const string& str,
const string& with, int64_t count) {
346 for (
auto i = 0; i < count; i++) indentString+= with;
347 return indentString + str;
356 inline static const string generate(
const string& what, int64_t count = 1) {
358 for (
auto i = 0; i < count; i++) result+= what;
375 static const string getUTF8CharAt(
const string& str, int64_t index);