Commit cf1400f7 authored by Sebastian Wolf's avatar Sebastian Wolf

Added contains for strings

parent 8dd67869
......@@ -37,6 +37,9 @@ namespace xerus {
///@brief: Explodes a string at positions indicated by _delim.
std::vector<std::string> explode(const std::string& _string, const char _delim);
///@brief: Returns true if _string contains _search as a substring.
bool contains(const std::string& _string, const std::string& _search);
///@brief: Replaces all occurences of _search in _string by _replace.
void replace(std::string& _string, const std::string& _search, const std::string& _replace);
......
......@@ -63,6 +63,10 @@ namespace xerus {
}
bool contains(const std::string& _string, const std::string& _search) {
return _string.find(_search) != std::string::npos;
}
void replace(std::string& _string, const std::string& _search, const std::string& _replace) {
size_t pos = 0;
while((pos = _string.find(_search, pos)) != std::string::npos){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment