12 using std::string_view;
30 inline static const bool startsWith(
const string& src,
const string& prefix) {
31 return src.find(prefix) == 0;
40 inline static const bool viewStartsWith(
const string_view& src,
const string& prefix) {
41 return src.find(prefix) == 0;
50 inline static const bool endsWith(
const string& src,
const string& suffix) {
52 src.size() >= suffix.size() &&
53 src.compare(src.size() - suffix.size(), suffix.size(), suffix) == 0;
62 inline static const bool viewEndsWith(
const string_view& src,
const string& suffix) {
64 src.size() >= suffix.size() &&
65 src.compare(src.size() - suffix.size(), suffix.size(), suffix) == 0;
76 static const string replace(
const string& src,
const char what,
const char by,
int beginIndex = 0);
86 static const string replace(
const string& src,
const string& what,
const string& by,
int beginIndex = 0);
95 inline static int32_t
indexOf(
const string& src,
char what,
int beginIndex = 0) {
96 return src.find(what, beginIndex);
106 inline static int32_t
indexOf(
const string& src,
const string& what,
int beginIndex = 0) {
107 return src.find(what, beginIndex);
117 inline static int32_t
firstIndexOf(
const string& src,
char what,
int beginIndex = 0) {
118 return src.find_first_of(what, beginIndex);
128 inline static int32_t
firstIndexOf(
const string& src,
const string& what,
int beginIndex = 0) {
129 return src.find_first_of(what, beginIndex);
139 inline static int32_t
lastIndexOf(
const string& src,
char what,
int beginIndex = -1) {
140 return src.find_last_of(what, beginIndex);
150 inline static int32_t
lastIndexOf(
const string& src,
const string& what,
int beginIndex = -1) {
151 return src.find_last_of(what, beginIndex);
160 inline static const string substring(
const string& src, int32_t beginIndex) {
161 return src.substr(beginIndex);
170 inline static const string_view
viewSubstring(
const string_view& src, int32_t beginIndex) {
171 return src.substr(beginIndex);
181 inline static const string substring(
const string& src, int32_t beginIndex, int32_t endIndex) {
182 return src.substr(beginIndex, endIndex - beginIndex);
192 inline static const string_view
viewSubstring(
const string_view& src, int32_t beginIndex, int32_t endIndex) {
193 return src.substr(beginIndex, endIndex - beginIndex);
209 static const string trim(
const string& src);
216 static const string_view
viewTrim(
const string_view& src);
223 static const string toLowerCase(
const string& src);
230 static const string toUpperCase(
const string& src);
238 static bool regexMatch(
const string& src,
const string& pattern);
246 static bool regexSearch(
const string& src,
const string& pattern);
254 static const string regexReplace(
const string& src,
const string& pattern,
const string& by);
263 static const vector<string>
tokenize(
const string& str,
const string& delimiters,
bool emptyTokens =
false);
271 inline static const string padLeft(
const string& src,
const string& by,
int toSize) {
273 while (result.size() < toSize) result = by + result;
283 inline static const string padRight(
const string& src,
const string& by,
int toSize) {
285 while (result.size() < toSize) result = result + by;
295 inline static const string indent(
const string& src,
const string& with,
int count) {
297 for (
auto i = 0; i < count; i++) indentString+= with;
298 return indentString + src;
UTF8 string character iterator.
int getBinaryPosition() const
int getCharacterPosition() const
void seekCharacterPosition(int position) const
Seek character position.