2023-01-07 11:24:02 -05:00
|
|
|
#pragma once
|
|
|
|
|
2022-11-29 19:22:22 -05:00
|
|
|
#include <string>
|
2023-01-07 11:24:02 -05:00
|
|
|
#include <vector>
|
2022-11-29 19:22:22 -05:00
|
|
|
|
|
|
|
namespace str_util {
|
2023-01-02 09:45:38 -05:00
|
|
|
bool contains(const std::string& s, const std::string& substr);
|
2022-11-29 19:22:22 -05:00
|
|
|
bool starts_with(const std::string& s, const std::string& prefix);
|
2023-05-21 17:24:23 -04:00
|
|
|
bool ends_with(const std::string& s, const std::string& suffix);
|
2022-11-29 19:22:22 -05:00
|
|
|
std::string ltrim(const std::string& s);
|
|
|
|
std::string rtrim(const std::string& s);
|
|
|
|
std::string trim(const std::string& s);
|
2023-01-15 11:33:39 -05:00
|
|
|
/// Given a string with new-lines, split and trim the leading whitespace from each line
|
|
|
|
/// then return the string with the new-lines back in place.
|
|
|
|
std::string trim_newline_indents(const std::string& s);
|
2022-12-22 13:41:33 -05:00
|
|
|
int line_count(const std::string& str);
|
2023-01-02 09:45:38 -05:00
|
|
|
bool valid_regex(const std::string& regex);
|
2023-01-07 11:24:02 -05:00
|
|
|
std::string diff(const std::string& lhs, const std::string& rhs);
|
|
|
|
/// Default splits on \n characters
|
|
|
|
std::vector<std::string> split(const ::std::string& str, char delimiter = '\n');
|
2023-01-15 11:33:39 -05:00
|
|
|
std::string join(const std::vector<std::string>& strs, const std::string& join_with);
|
2023-02-20 19:49:37 -05:00
|
|
|
std::vector<std::string> regex_get_capture_groups(const std::string& str, const std::string& regex);
|
2023-04-24 23:46:55 -04:00
|
|
|
bool replace(std::string& str, const std::string& from, const std::string& to);
|
2023-05-21 17:24:23 -04:00
|
|
|
std::string uuid();
|
2022-11-29 19:22:22 -05:00
|
|
|
} // namespace str_util
|