Home » U++ Library support » U++ Core » Looking for examples to split string into container
Re: Looking for examples to split string into container [message #55311 is a reply to message #55309] |
Wed, 28 October 2020 19:07   |
Oblivion
Messages: 1212 Registered: August 2007
|
Senior Contributor |
|
|
HEllo David,
Klugier already pointed to the right function and interface (Upp::Split).
Upp::Split has a plenty of variants, just check the API docs.
Here is conversion of C# -> to U++ code:
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
String text = "one\ttwo three:four,five six seven";
Cout() << text << "\n";
Vector<String> words = Split(text, [](int c) { return c == ':' || c == '\t' || c == ' ' || c == ',' || c == '.' ? 1 : 0; });
for(const auto& s : words)
Cout() << s << "\n";
}
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
|
|
|
Goto Forum:
Current Time: Mon Jun 16 12:50:38 CEST 2025
Total time taken to generate the page: 0.04324 seconds
|