diff options
| author | louis <louis.braun@gmx.de> | 2013-08-30 16:10:51 +0200 |
|---|---|---|
| committer | louis <louis.braun@gmx.de> | 2013-08-30 16:10:51 +0200 |
| commit | b503c5238ea1593c209d0a9cdfd8bca29efe90c3 (patch) | |
| tree | 9efa926f72a8491dc8eca22bd119204e1766abb5 /tools | |
| parent | 2e460f46395dd61931d3dd431a7ad8dd465f1b81 (diff) | |
| download | vdr-plugin-tvscraper-b503c5238ea1593c209d0a9cdfd8bca29efe90c3.tar.gz vdr-plugin-tvscraper-b503c5238ea1593c209d0a9cdfd8bca29efe90c3.tar.bz2 | |
Version 0.0.4
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/stringhelpers.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/stringhelpers.c b/tools/stringhelpers.c new file mode 100644 index 0000000..2eb3c8c --- /dev/null +++ b/tools/stringhelpers.c @@ -0,0 +1,20 @@ +using namespace std; +//replace all "search" with "replace" in "subject" +string str_replace(const string& search, const string& replace, const string& subject) { + string str = subject; + size_t pos = 0; + while((pos = str.find(search, pos)) != string::npos) { + str.replace(pos, search.length(), replace); + pos += replace.length(); + } + return str; +} +//cut string after first "search" +string str_cut(const string& search, const string& subject) { + string str = subject; + size_t found = str.find_first_of(search); + if (found != string::npos) { + return str.substr(0, found); + } + return ""; +} |
