diff --git a/ZString.cpp b/ZString.cpp index 9585b6f..668c195 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -291,9 +291,16 @@ namespace coreutils { } ZString ZString::getTokenExclude(const char *exclude) { + char previous = 0; char *start = cursor; - while ((cursor <= (data + length)) && !isCharacter(*cursor, exclude)) - ++cursor; + do { + while ((cursor <= (data + length)) && !isCharacter(*cursor, exclude)) { + previous = *cursor; + ++cursor; + } + ++cursor; + } while(previous == '\\'); + --cursor; return ZString(start, cursor - start); } diff --git a/testing/zstring_test.cpp b/testing/zstring_test.cpp index b568634..c76b329 100644 --- a/testing/zstring_test.cpp +++ b/testing/zstring_test.cpp @@ -111,5 +111,9 @@ int main(int argc, char **argv) { coreutils::ZString test21("10.00000000"); std::cout << "Trailing Zeros: " << test21.removeTrailingZeros() << std::endl; std::cout << " " << test21 << std::endl; + + coreutils::ZString test22("This is a \\\"quoted\\\" string.\""); + std::cout << "quoted string: " << test22 << std::endl; + std::cout << "quoted string: " << test22.getTokenExclude("\"") << std::endl; }