17 std::vector<std::string>
split(std::string_view input, std::string_view delim)
noexcept
19 std::size_t start = 0;
22 std::vector<std::string> splits;
23 while ((start = input.find_first_not_of(delim, end)) != std::string::npos)
25 end = input.find(delim, start);
27 const auto split = input.substr(start, end - start);
30 splits.emplace_back(
split);
37 std::string
replace_first(std::string input, std::string_view to_replace, std::string_view replace_with)
noexcept
39 const auto pos = input.find(to_replace);
41 if (pos != std::string::npos)
43 input.replace(pos, to_replace.length(), replace_with);
49 std::string
replace_all(std::string input, std::string_view to_replace, std::string_view replace_with)
noexcept
53 while (pos != std::string::npos)
55 pos = input.find(to_replace, pos);
57 if (pos != std::string::npos)
59 input.replace(pos, to_replace.length(), replace_with);
66 bool begins_with(
const std::string& input,
const std::string& find)
noexcept
68 return (input.rfind(find, 0) == 0);
71 std::string
ltrim(std::string input)
noexcept
74 input.erase(input.begin(), std::find_if(input.begin(), input.end(), [](
const auto ch) {
75 return !std::isspace(ch);
81 std::string
rtrim(std::string input)
noexcept
83 input.erase(std::find_if(input.rbegin(), input.rend(), [](
const auto ch) {
84 return !std::isspace(ch);
85 }).base(), input.end());
91 std::string
trim(std::string input)
noexcept
101 const auto trim_from = std::unique(input.begin(), input.end(), [](
const auto lhs,
const auto rhs) {
102 return (lhs == rhs) && (lhs ==
' ');
105 input.erase(trim_from, input.end());
106 input.shrink_to_fit();
std::string rtrim(std::string input) noexcept
Trim string from start.
std::string replace_all(std::string input, std::string_view to_replace, std::string_view replace_with) noexcept
Replaces all occurrences of a string.
std::vector< std::string > split(std::string_view input, std::string_view delim) noexcept
Split a string based on a delimiter.
std::string ltrim(std::string input) noexcept
Trim string from end.
bool begins_with(const std::string &input, const std::string &find) noexcept
Check if string begins with another string.
std::string trim(std::string input) noexcept
Trim both ends of string.
std::string make_single_spaced(std::string input) noexcept
Make a string single spaced.
std::string replace_first(std::string input, std::string_view to_replace, std::string_view replace_with) noexcept
Replace first occurrence of a string.