#3841 Add compare to RiaStdStringTools

This commit is contained in:
Magne Sjaastad 2018-12-14 09:20:28 +01:00
parent d6e40f25ff
commit 560549a5cb
2 changed files with 15 additions and 0 deletions

View File

@ -102,6 +102,17 @@ bool RiaStdStringTools::startsWithAlphabetic(const std::string& s)
return isalpha(s[0]) != 0; return isalpha(s[0]) != 0;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaStdStringTools::endsWith(const std::string& mainStr, const std::string& toMatch)
{
if (mainStr.size() >= toMatch.size() && mainStr.compare(mainStr.size() - toMatch.size(), toMatch.size(), toMatch) == 0)
return true;
else
return false;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -127,3 +138,4 @@ size_t RiaStdStringTools::findCharMatchCount(const std::string& s, char c)
} }
return count; return count;
} }

View File

@ -39,6 +39,9 @@ public:
static bool containsAlphabetic(const std::string& s); static bool containsAlphabetic(const std::string& s);
static bool startsWithAlphabetic(const std::string& s); static bool startsWithAlphabetic(const std::string& s);
static bool endsWith(const std::string& mainStr, const std::string& toMatch);
static std::vector<std::string> splitStringBySpace(const std::string& s); static std::vector<std::string> splitStringBySpace(const std::string& s);
private: private: