From c9fa7e3832cfa38e18fec25d27eeb229b96068cf Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 2 Sep 2013 10:58:30 +0200 Subject: str_cut now removes ending space --- tools/stringhelpers.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/stringhelpers.c b/tools/stringhelpers.c index 2eb3c8c..48bbc46 100644 --- a/tools/stringhelpers.c +++ b/tools/stringhelpers.c @@ -12,9 +12,14 @@ string str_replace(const string& search, const string& replace, const string& su //cut string after first "search" string str_cut(const string& search, const string& subject) { string str = subject; + string strCutted = ""; size_t found = str.find_first_of(search); if (found != string::npos) { - return str.substr(0, found); + strCutted = str.substr(0, found); + size_t foundSpace = strCutted.find_last_of(" "); + if ((foundSpace != string::npos) && (foundSpace == (strCutted.size()-1))) { + strCutted = strCutted.substr(0, strCutted.size()-1); + } } - return ""; + return strCutted; } -- cgit v1.2.3