#include#include using namespace std; using namespace icu; int main() { UnicodeString ustr("Hello, World!"); int index = ustr.indexOf("World"); // searching for "World" substring if(index != -1) { cout << "Substring found at index: " << index << endl; } else { cout << "Substring not found."; } return 0; }
#includeThis code sample creates a UnicodeString object and searches for all occurrences of a specific substring "is". It makes use of a while loop to find and print the index of each occurrence. The UnicodeString object and its methods are part of the ICU (International Components for Unicode) library package.#include using namespace std; using namespace icu; int main() { UnicodeString ustr("This is a test string."); int index = ustr.indexOf("is"); // searching for "is" substring while (index >= 0) { cout << "Substring found at index: " << index << endl; index = ustr.indexOf("is", index + 1); // searching for next occurrence } return 0; }