StringUtils: Fixed StringSplit to work with multiple delimiters
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1438 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
bdc06b6e74
commit
d55416a649
@ -106,7 +106,7 @@ AStringVector StringSplit(const AString & str, const AString & delim)
|
|||||||
while ((cutAt = str.find_first_of(delim, Prev)) != str.npos)
|
while ((cutAt = str.find_first_of(delim, Prev)) != str.npos)
|
||||||
{
|
{
|
||||||
results.push_back(str.substr(Prev, cutAt - Prev));
|
results.push_back(str.substr(Prev, cutAt - Prev));
|
||||||
Prev = cutAt + delim.length();
|
Prev = cutAt + 1;
|
||||||
}
|
}
|
||||||
if (Prev < str.length())
|
if (Prev < str.length())
|
||||||
{
|
{
|
||||||
@ -118,6 +118,7 @@ AStringVector StringSplit(const AString & str, const AString & delim)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AStringVector StringSplitAndTrim(const AString & str, const AString & delim)
|
AStringVector StringSplitAndTrim(const AString & str, const AString & delim)
|
||||||
{
|
{
|
||||||
AStringVector results;
|
AStringVector results;
|
||||||
@ -126,7 +127,7 @@ AStringVector StringSplitAndTrim(const AString & str, const AString & delim)
|
|||||||
while ((cutAt = str.find_first_of(delim, Prev)) != str.npos)
|
while ((cutAt = str.find_first_of(delim, Prev)) != str.npos)
|
||||||
{
|
{
|
||||||
results.push_back(TrimString(str.substr(Prev, cutAt - Prev)));
|
results.push_back(TrimString(str.substr(Prev, cutAt - Prev)));
|
||||||
Prev = cutAt + delim.length();
|
Prev = cutAt + 1;
|
||||||
}
|
}
|
||||||
if (Prev < str.length())
|
if (Prev < str.length())
|
||||||
{
|
{
|
||||||
|
@ -33,10 +33,10 @@ extern AString Printf(const char * format, ...);
|
|||||||
/// Add the formatted string to the existing data in the string
|
/// Add the formatted string to the existing data in the string
|
||||||
extern AString & AppendPrintf (AString & str, const char * format, ...);
|
extern AString & AppendPrintf (AString & str, const char * format, ...);
|
||||||
|
|
||||||
/// Split the string at delimiters, return as a stringvector
|
/// Split the string at any of the listed delimiters, return as a stringvector
|
||||||
extern AStringVector StringSplit(const AString & str, const AString & delim);
|
extern AStringVector StringSplit(const AString & str, const AString & delim);
|
||||||
|
|
||||||
/// Split the string at delimiters and trim each value, return as a stringvector
|
/// Split the string at any of the listed delimiters and trim each value, return as a stringvector
|
||||||
extern AStringVector StringSplitAndTrim(const AString & str, const AString & delim);
|
extern AStringVector StringSplitAndTrim(const AString & str, const AString & delim);
|
||||||
|
|
||||||
/// Trime whitespace at both ends of the string
|
/// Trime whitespace at both ends of the string
|
||||||
|
Loading…
Reference in New Issue
Block a user