11using std::string_view;
29 inline static const bool startsWith(
const string& src,
const string& prefix) {
30 return src.find(prefix) == 0;
39 inline static const bool viewStartsWith(
const string_view& src,
const string& prefix) {
40 return src.find(prefix) == 0;
49 inline static const bool endsWith(
const string& src,
const string& suffix) {
51 src.size() >= suffix.size() &&
52 src.compare(src.size() - suffix.size(), suffix.size(), suffix) == 0;
61 inline static const bool viewEndsWith(
const string_view& src,
const string& suffix) {
63 src.size() >= suffix.size() &&
64 src.compare(src.size() - suffix.size(), suffix.size(), suffix) == 0;
75 static const string replace(
const string& src,
const char what,
const char by,
int beginIndex = 0);
85 static const string replace(
const string& src,
const string& what,
const string& by,
int beginIndex = 0);
94 return src.find_first_of(what);
103 inline static int32_t
firstIndexOf(
const string& src,
const string& what) {
104 return src.find_first_of(what);
114 return src.find_last_of(what);
123 inline static int32_t
lastIndexOf(
const string& src,
const string& what) {
124 return src.find_last_of(what);
133 inline static const string substring(
const string& src, int32_t beginIndex) {
134 return src.substr(beginIndex);
143 inline static const string_view
viewSubstring(
const string_view& src, int32_t beginIndex) {
144 return src.substr(beginIndex);
154 inline static const string substring(
const string& src, int32_t beginIndex, int32_t endIndex) {
155 return src.substr(beginIndex, endIndex - beginIndex);
165 inline static const string_view
viewSubstring(
const string_view& src, int32_t beginIndex, int32_t endIndex) {
166 return src.substr(beginIndex, endIndex - beginIndex);
182 static const string trim(
const string& src);
189 static const string_view
viewTrim(
const string_view& src);
196 static const string toLowerCase(
const string& src);
203 static const string toUpperCase(
const string& src);
211 static bool regexMatch(
const string& src,
const string& pattern);
219 static const string regexReplace(
const string& src,
const string& pattern,
const string& by);
227 static const vector<string>
tokenize(
const string& str,
const string& delimiters);