split by regexp and [rl]tring added
This commit is contained in:
@@ -30,6 +30,29 @@ bool regexp_search(const std::string &where, const std::string ®ex_str) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> regexp_strsplit(const std::string &string_to_split, const std::string &rgx_str) {
|
||||
std::vector<std::string> elems;
|
||||
|
||||
std::regex rgx(rgx_str);
|
||||
std::sregex_token_iterator iter(string_to_split.begin(), string_to_split.end(), rgx, -1);
|
||||
std::sregex_token_iterator end;
|
||||
|
||||
for (; iter != end; ++iter)
|
||||
elems.push_back(*iter);
|
||||
|
||||
return elems;
|
||||
}
|
||||
|
||||
std::string trim(std::string s, const std::string &chars_to_trim, const std::string &rltrim) {
|
||||
if (rltrim == "ltrim" || rltrim == "trim")
|
||||
s.erase(0, s.find_first_not_of(chars_to_trim));
|
||||
|
||||
if (rltrim == "rtrim" || rltrim == "trim")
|
||||
s.erase(s.find_last_not_of(chars_to_trim)+1);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string string_padd(const std::string &str, int pad_len, char fill_char, bool from_right) {
|
||||
int str_len = str.length();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user