Creating an RWUStringSearch
RWUStringSearch objects are created given:
an
RWUString that specifies the pattern to search for
an
RWUCollator that encapsulates locale-sensitive string comparison rules (see Chapter 6)
If an
RWUBreakSearch is used, a substring is considered a match only if it falls on boundaries returned by the break search object. This makes it possible, for example, to search for entire words or entire sentences.
For example, this code creates an
RWUStringSearch that can be used to search the
RWUString text for occurrences of
RWUString pattern using the string comparison rules encapsulated by
RWUCollator collator:
RWUConversionContext context("UTF-8"); //1
RWUString pattern("UTF-8"); //2
RWUString text("Utf8 serializes a Unicode code point "
"as a sequence of one to four bytes. Table 3-1 of "
"The Unicode Standard shows the bit distribution used "
"in utf-8.");
RWUCollator collator; //3
collator.setStrength(RWUCollator::Primary);
collator.enablePunctuationShifting(true);
RWUStringSearch searcher(pattern, text, collator);