mirror of
https://github.com/matrix-construct/construct
synced 2025-02-16 16:50:12 +01:00
ircd: Add stringops rsplit().
This commit is contained in:
parent
fedeab2ddd
commit
b44eb91437
1 changed files with 10 additions and 0 deletions
|
@ -42,6 +42,7 @@ std::string token_last(const std::string &str, const char *const &sep);
|
|||
|
||||
std::string chomp(const std::string &str, const std::string &c = " "s);
|
||||
std::pair<std::string, std::string> split(const std::string &str, const std::string &delim = " "s);
|
||||
std::pair<std::string, std::string> rsplit(const std::string &str, const std::string &delim = " "s);
|
||||
std::string between(const std::string &str, const std::string &a = "("s, const std::string &b = ")"s);
|
||||
bool endswith(const std::string &str, const char *const &val);
|
||||
bool endswith(const std::string &str, const std::string &val);
|
||||
|
@ -126,6 +127,15 @@ ircd::between(const std::string &str,
|
|||
}
|
||||
|
||||
|
||||
inline std::pair<std::string, std::string>
|
||||
ircd::rsplit(const std::string &str,
|
||||
const std::string &delim)
|
||||
{
|
||||
const auto pos(str.find_last_of(delim));
|
||||
return pos == std::string::npos? std::make_pair(std::string{}, str):
|
||||
std::make_pair(str.substr(0, pos), str.substr(pos+delim.size()));
|
||||
}
|
||||
|
||||
inline std::pair<std::string, std::string>
|
||||
ircd::split(const std::string &str,
|
||||
const std::string &delim)
|
||||
|
|
Loading…
Add table
Reference in a new issue