An open API service indexing awesome lists of open source software.

https://github.com/dacap/tok

A minimalist C++ library to iterate through string tokens
https://github.com/dacap/tok

cpp cpp-library cpp11 header-only

Last synced: 6 months ago
JSON representation

A minimalist C++ library to iterate through string tokens

Awesome Lists containing this project

README

          

# tok

A minimalist C++ library to iterate through string tokens:

```c++
#include
#include
#include "tok.h"

int main() {
// Prints:
// "This"
// "is"
// "a"
// "phrase."
// "Several"
// "whitespaces"
// "are"
// "ignored."
std::string a = "This is a phrase. Several whitespaces are ignored.";
for (auto& tok : tok::split_tokens(a, ' ')) {
std::cout << "\"" << tok << "\"\n";
}

// Prints:
// "In comma"
// "separated"
// ""
// "values"
// ""
// ""
// "empties are included"
std::string b = "In comma,separated,,values,,,empties are included";
for (auto& tok : tok::csv(b)) {
std::cout << "\"" << tok << "\"\n";
}
}
```