Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Oblivion is currently offline  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


 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Vector a user defined struct for XML persistency
Next Topic: Convert struct to string and reconstruct a struct from string
Goto Forum:
  


Current Time: Mon Jun 16 12:50:38 CEST 2025

Total time taken to generate the page: 0.04324 seconds