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
- Host: GitHub
- URL: https://github.com/dacap/tok
- Owner: dacap
- License: mit
- Created: 2020-07-16T02:51:35.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-16T22:23:42.000Z (almost 2 years ago)
- Last Synced: 2025-10-12T12:55:43.796Z (6 months ago)
- Topics: cpp, cpp-library, cpp11, header-only
- Language: C++
- Homepage:
- Size: 6.84 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
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";
}
}
```