-
Notifications
You must be signed in to change notification settings - Fork 0
/
split.h
33 lines (27 loc) · 1.38 KB
/
split.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// ******************************************************
// vcfCTools (c) 2011 Alistair Ward
// Marth Lab, Department of Biology, Boston College
// All rights reserved.
// ------------------------------------------------------
// Last modified: 18 February 2011
// ------------------------------------------------------
// String split method.
// Thanks to Evan Teran, http://stackoverflow.com/
// questions/236129/how-to-split-a-string/236803#236803
// ******************************************************
#ifndef SPLIT_H
#define SPLIT_H
#include <string>
#include <vector>
#include <sstream>
#include <string.h>
// split a string on a single delimiter character (delim)
std::vector<std::string>& split(const std::string &s, char delim, std::vector<std::string> &elems);
std::vector<std::string> split(const std::string &s, char delim);
// split a string on a single delimiter character, but only find the first n splits.
std::vector<std::string>& split(const std::string &s, char delim, std::vector<std::string> &elems, int &n);
std::vector<std::string> split(const std::string &s, char delim, int n);
// split a string on any character found in the string of delimiters (delims)
std::vector<std::string>& split(const std::string &s, const std::string& delims, std::vector<std::string> &elems);
std::vector<std::string> split(const std::string &s, const std::string& delims);
#endif // SPLIT_H