Comparing string spans

The TSpanTextPatternIterator class iterates through a text string, returning contiguous ranges of characters that either include or exclude the characters in the pattern. This iterator provides functionality similar to the C string span functions.

The pattern is interpreted as a set of individual characters that can be matched in any order and in any combination. You set the iterator to perform either inclusive or exclusive matching.


When you create this iterator, you must specify an ESpanType value indicating whether the matching should be inclusive or exclusive. TSpanTextPatternIterator provides no default behavior.

For example, this code tokenizes text by locating ranges of text bounded by the space character:

      TStandardText spanText(" ");
      TSpanTextPatternIterator iterator(&searchText, spanText,
           TSpanTextPatternIterator::kExclusive);
      
      TTextRange wordRange;
      for (TTextOffset wordOffset = iterator.First(wordRange);
          wordOffset != TTextPatternIterator::kNotFoundOffset;
          wordOffset = iterator.Next(wordRange)) 
      {
          // Do something interesting...
      }

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker