#include#include "llvm/ADT/StringRef.h" using namespace llvm; int main() { StringRef str = "Hello World"; std::vector substrings; str.split(substrings, " "); for(auto sub : substrings) { std::cout << sub.str() << std::endl; } return 0; }
Hello World
#include#include "llvm/ADT/StringRef.h" using namespace llvm; int main() { StringRef str = "Hello_World/How-Are-You?"; std::vector substrings; str.split(substrings, "_/-?"); for(auto sub : substrings) { std::cout << sub.str() << std::endl; } return 0; }
Hello World How Are YouIn this example, we have split the string "Hello_World/How-Are-You?" using multiple delimiters - "_", "/", "-", and "?". The split function has split the string into five substrings - "Hello", "World", "How", "Are", and "You". The substrings are then printed using a for-each loop. Therefore, the package library used for this function is LLVM.