Clownfish::StringIterator - Iterate Unicode code points in a String.
my $iter = $string->top; while (my $code_point = $iter->next) { ... }
my $result = $string_iterator->clone();
Return a clone of the object.
$string_iterator->assign($other);
Assign the source string and current position of other
to self
.
my $int = $string_iterator->compare_to($other);
Indicate whether one StringIterator is less than,
equal to,
or greater than another by comparing their character positions.
Throws an exception if other
is not a StringIterator pointing to the same source string as self
.
Returns: 0 if the StringIterators are equal,
a negative number if self
is less than other
,
and a positive number if self
is greater than other
.
my $bool = $string_iterator->has_next();
Return true if the iterator is not at the end of the string.
my $bool = $string_iterator->has_prev();
Return true if the iterator is not at the start of the string.
my $code_point = $iter->next;
Return the code point after the current position and advance the iterator. Returns undef at the end of the string. Returns zero but true for U+0000.
my $code_point = $iter->prev;
Return the code point before the current position and go one step back. Returns undef at the start of the string. Returns zero but true for U+0000.
my $int = $string_iterator->advance($num);
Skip code points.
Returns: the number of code points actually skipped. This can be less than the requested number if the end of the string is reached.
my $int = $string_iterator->recede($num);
Skip code points backward.
Returns: the number of code points actually skipped. This can be less than the requested number if the start of the string is reached.
my $int = $string_iterator->skip_whitespace();
Skip whitespace.
Whitespace is any character that has the Unicode property White_Space
.
Returns: the number of code points skipped.
my $int = $string_iterator->skip_whitespace_back();
Skip whitespace backward.
Whitespace is any character that has the Unicode property White_Space
.
Returns: the number of code points skipped.
my $bool = $string_iterator->starts_with($prefix);
Test whether the content after the iterator starts with prefix
.
my $bool = $string_iterator->ends_with($suffix);
Test whether the content before the iterator ends with suffix
.
Clownfish::StringIterator isa Clownfish::Obj.
Copyright © 2010-2015 The Apache Software Foundation, Licensed under the
Apache License, Version 2.0.
Apache Lucy, Lucy, Apache, the Apache feather logo, and the Apache Lucy project logo are trademarks of The
Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their
respective owners.