summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'segget/str.cpp')
-rw-r--r--segget/str.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/segget/str.cpp b/segget/str.cpp
index 4ffbe2f..592e0cd 100644
--- a/segget/str.cpp
+++ b/segget/str.cpp
@@ -106,6 +106,19 @@ string noupper(string s){
}
}
+bool split(string splitter, string str, string &before, string &after){
+ try{
+ uint splitter_pos=str.find(splitter);
+ if (splitter_pos==str.npos) return 1;
+ before=str.substr(0,splitter_pos);
+ after=str.substr(splitter_pos+splitter.length());
+ return 0;
+ }catch(...){
+ error_log("Error in str.cpp: split()");
+ return 1;
+ }
+}
+
string trim(std::string const& source, char const* delims) {
try{
string result(source);