[c++] Split a string using C++11

What would be easiest method to split a string using c++11?

I've seen the method used by this post, but I feel that there ought to be a less verbose way of doing it using the new standard.

Edit: I would like to have a vector<string> as a result and be able to delimitate on a single character.

This question is related to c++ string split c++11

The answer is


Questions with c++ tag:

Method Call Chaining; returning a pointer vs a reference? How can I tell if an algorithm is efficient? Difference between opening a file in binary vs text How can compare-and-swap be used for a wait-free mutual exclusion for any shared data structure? Install Qt on Ubuntu #include errors detected in vscode Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio 2017 errors on standard headers How do I check if a Key is pressed on C++ How to enable C++17 compiling in Visual Studio? Remove from the beginning of std::vector Why does C++ code for testing the Collatz conjecture run faster than hand-written assembly? What is (x & 1) and (x >>= 1)? What are the new features in C++17? Visual Studio Code includePath Compiling an application for use in highly radioactive environments "No rule to make target 'install'"... But Makefile exists How to build and use Google TensorFlow C++ api Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) Converting std::__cxx11::string to std::string lvalue required as left operand of assignment error when using C++ How to overcome "'aclocal-1.15' is missing on your system" warning? MSVCP140.dll missing How to get image width and height in OpenCV? CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found Reading json files in C++ What exactly is std::atomic? Compile c++14-code with g++ Visual Studio 2015 doesn't have cl.exe Visual Studio 2013 error MS8020 Build tools v140 cannot be found CMake does not find Visual C++ compiler Casting int to bool in C/C++ C++ How do I convert a std::chrono::time_point to long and back How can I get the size of an std::vector as an int? Significance of ios_base::sync_with_stdio(false); cin.tie(NULL); Fatal error: iostream: No such file or directory in compiling C program using GCC unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2 How to end C++ code How to change text color and console color in code::blocks? Error: stray '\240' in program invalid use of non-static member function Convert float to string with precision & number of decimal digits specified? enum to string in modern C++11 / C++14 / C++17 and future C++20 Passing capturing lambda as function pointer How do I add a library path in cmake? error: expected primary-expression before ')' token (C) undefined reference to 'std::cout' java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader fatal error: mpi.h: No such file or directory #include <mpi.h>

Questions with string tag:

How to split a string in two and store it in a field String method cannot be found in a main class method Kotlin - How to correctly concatenate a String Replacing a character from a certain index Remove quotes from String in Python Detect whether a Python string is a number or a letter How does String substring work in Swift How does String.Index work in Swift swift 3.0 Data to String? How to parse JSON string in Typescript How to change the datetime format in pandas How to write to a CSV line by line? convert string to number node.js "error: assignment to expression with array type error" when I assign a struct field (C) Remove 'b' character do in front of a string literal in Python 3 Ruby: How to convert a string to boolean What does ${} (dollar sign and curly braces) mean in a string in Javascript? How do I make a new line in swift converting json to string in python PHP - remove all non-numeric characters from a string C# - How to convert string to char? How can I remove the last character of a string in python? Converting std::__cxx11::string to std::string How to convert string to date to string in Swift iOS? Convert time.Time to string TypeError: a bytes-like object is required, not 'str' when writing to a file in Python3 How can I capitalize the first letter of each word in a string using JavaScript? Best way to verify string is empty or null Hive cast string to date dd-MM-yyyy Check for special characters in string How to convert any Object to String? Print "\n" or newline characters as part of the output on terminal Set the maximum character length of a UITextField in Swift How do I convert a Python 3 byte-string variable into a regular string? What does $ mean before a string? Delete the last two characters of the String Splitting a string into separate variables Figure out size of UILabel based on String in Swift Matching strings with wildcard How do I concatenate strings? Print very long string completely in pandas dataframe Check string for nil & empty Convert float to string with precision & number of decimal digits specified? How do I print my Java object without getting "SomeType@2f92e0f4"? enum to string in modern C++11 / C++14 / C++17 and future C++20 How should I remove all the leading spaces from a string? - swift Convert array to JSON string in swift Swift extract regex matches Convert a file path to Uri in Android How would I get everything before a : in a string Python

Questions with split tag:

Parameter "stratify" from method "train_test_split" (scikit Learn) Pandas split DataFrame by column value How to split large text file in windows? Attribute Error: 'list' object has no attribute 'split' Split function in oracle to comma separated values with automatic sequence How would I get everything before a : in a string Python Split String by delimiter position using oracle SQL JavaScript split String with white space Split a String into an array in Swift? Split pandas dataframe in two if it has more than 10 rows Split text file into smaller multiple text file using command line How to split a python string on new line characters Uncaught TypeError: Cannot read property 'split' of undefined Split string with string as delimiter Split text with '\r\n' Split string in JavaScript and detect line break How to split CSV files as per number of rows specified? Splitting dataframe into multiple dataframes Splitting a dataframe string column into multiple different columns Get first word of string Split a large dataframe into a list of data frames based on common value in column split string only on first instance - java Regex to split a CSV Python 2: AttributeError: 'list' object has no attribute 'strip' splitting a string based on tab in the file Excel CSV. file with more than 1,048,576 rows of data Reading a text file and splitting it into single words in python Split a string into array in Perl Java equivalent to Explode and Implode(PHP) How to split a string at the first `/` (slash) and surround part of it in a `<span>`? How to split a string and assign it to variables Splitting String with delimiter how to get the last part of a string before a certain character? Split string into tokens and save them in an array Splitting on last delimiter in Python string? How to split the name string in mysql? Java string split with "." (dot) Java String split removed empty values Java replace all square brackets in a string Java split string to array Parse (split) a string in C++ using string delimiter (standard C++) How to extract a string between two delimiters Split string based on regex String split on new line, tab and some number of spaces Split a List into smaller lists of N size T-SQL split string How to split a comma-separated string? How to split a string into an array in Bash? What is causing the error `string.split is not a function`? Python read in string from file and split it into values

Questions with c++11 tag:

Remove from the beginning of std::vector Converting std::__cxx11::string to std::string What exactly is std::atomic? C++ How do I convert a std::chrono::time_point to long and back Passing capturing lambda as function pointer undefined reference to 'std::cout' Is it possible to use std::string in a constexpr? How does #include <bits/stdc++.h> work in C++? error::make_unique is not a member of ‘std’ no match for ‘operator<<’ in ‘std::operator Why should I use a pointer rather than the object itself? Why is conversion from string constant to 'char*' valid in C but invalid in C++ Difference in make_shared and normal shared_ptr in C++ What is the logic behind the "using" keyword in C++? std::unique_lock<std::mutex> or std::lock_guard<std::mutex>? Pass multiple arguments into std::thread Correct way of looping through C++ arrays Generate random numbers using C++11 random library How do I use a custom deleter with a std::unique_ptr member? How to use bitmask? Program to find largest and smallest among 5 numbers without using array Why is list initialization (using curly braces) better than the alternatives? What is the 'override' keyword in C++ used for? How can I add C++11 support to Code::Blocks compiler? How to enable C++11 in Qt Creator? How do I enable C++11 in gcc? Is there any use for unique_ptr with array? Thread pooling in C++11 C++11 thread-safe queue cc1plus: error: unrecognized command line option "-std=c++11" with g++ How to create timer events using C++ 11? How do I pass multiple ints into a vector at once? How to get duration, as int milli's and float seconds from <chrono>? Iterator Loop vs index loop Difference between `constexpr` and `const` Does static constexpr variable inside a function make sense? const vs constexpr on variables initialize a vector to zeros C++/C++11 to_string is not a member of std, says g++ (mingw) How to convert std::chrono::time_point to calendar datetime string with fractional seconds? How do I terminate a thread in C++11? When is std::weak_ptr useful? How can I output the value of an enum class in C++11 std::thread calling method of class How do I activate C++ 11 in CMake? When should I really use noexcept? What is the difference between 'typedef' and 'using' in C++11? Start thread with member function Compiling C++11 with g++ Are the days of passing const std::string & as a parameter over?