4 #ifndef ILANG_UTIL_STR_UTIL_H__
5 #define ILANG_UTIL_STR_UTIL_H__
22 std::string
StrToUpper(
const std::string& str);
25 std::string
StrToLower(
const std::string& str);
31 int StrToInt(
const std::string& str,
int base = 10);
34 long long StrToLong(
const std::string& str,
int base = 10);
37 unsigned long long StrToULongLong(
const std::string& str,
int base = 10);
52 std::vector<std::string>
Split(
const std::string& str,
53 const std::string& delim);
59 std::string
Join(
const std::vector<std::string>& in,
const std::string& delim);
65 std::string
ReplaceAll(
const std::string& str,
const std::string& a,
66 const std::string& b);
69 std::vector<std::string>
ReFindList(
const std::string& s,
70 const std::string& re);
74 std::vector<std::string>
ReFindAndDo(
const std::string& s,
75 const std::string& re,
76 std::function<std::string(std::string)> f);
81 bool StrEndsWith(
const std::string& str,
const std::string& suffix);
84 bool StrStartsWith(
const std::string& str,
const std::string& prefix);
89 #endif // ILANG_UTIL_STR_UTIL_H__
std::string RemoveWhiteSpace(const std::string &in)
Remove whitespace " \n\t\r\f\v" from the input string.
std::string IntToStrCustomBase(uint64_t value, unsigned base, bool uppercase)
Transform int to string with different bases.
std::vector< std::string > ReFindAndDo(const std::string &s, const std::string &re, std::function< std::string(std::string)> f)
std::vector< std::string > ReFindList(const std::string &s, const std::string &re)
Filter out a list of substring by the regular expression.
void StrLeftTrim(std::string &s)
Trim a string from start (in place)
std::vector< std::string > SplitSpaceTabEnter(const std::string &str)
Python-style split behavior, delim: space tab enter and their combiniations.
bool StrStartsWith(const std::string &str, const std::string &prefix)
Finds out if str starts with prefix.
std::string StrToLower(const std::string &str)
Transform basic string to lower case.
bool StrToBool(const std::string &str)
Return true if string is "true" or "True".
void StrRightTrim(std::string &s)
Trim a string from end (in place)
std::string ReplaceAll(const std::string &str, const std::string &a, const std::string &b)
Replace all occurrance of substring a by substring b.
unsigned long long StrToULongLong(const std::string &str, int base=10)
Return the value represented in the string in unsigned long long, e.g. "10".
void StrTrim(std::string &s)
Trim a string from both ends (in place)
long long StrToLong(const std::string &str, int base=10)
Return the value represented in the string in long type, e.g. "10".
std::string StrToUpper(const std::string &str)
Transform basic string to upper case.
std::vector< std::string > Split(const std::string &str, const std::string &delim)
Python-style split , return a vector of splitted strings.
std::string Join(const std::vector< std::string > &in, const std::string &delim)
Python-style join, return a string that joins the list by the delim.
bool StrEndsWith(const std::string &str, const std::string &suffix)
Finds out if str ends with suffix.
int StrToInt(const std::string &str, int base=10)
Return the value represented in the string, e.g. "10".