Characters class

The characters of a string.

A character is a Unicode Grapheme cluster represented by a substring of the original string. The Characters class is an Iterable of those strings. However, unlike most iterables, many of the operations are eager. Since the underlying string is known in its entirety, and is known not to change, operations which select a subset of the elements can be computed eagerly, and in that case the operation returns a new Characters object.

The iterator provided by Characters is a CharacterRange which allows iterating the independent characters in both directions, but which also provides ways to select other ranges of characters in different ways.

Constructors

Characters(String string)
Creates a Characters allowing iteration of the characters of string.
factory

Properties

hashCode → int
The hash code of string.
read-only
iterator CharacterRange
Iterator over the characters of this string. [...]
read-only
iteratorAtEnd CharacterRange
Iterator over the characters of this string. [...]
read-only
string → String
The string to iterate over.
read-only
first → String
Returns the first element.
read-only, inherited
isEmpty → bool
Returns true if there are no elements in this collection.
read-only, inherited
isNotEmpty → bool
Returns true if there is at least one element in this collection.
read-only, inherited
last → String
Returns the last element.
read-only, inherited
length → int
Returns the number of elements in this.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
single → String
Checks that this iterable has only one element, and returns that element.
read-only, inherited

Methods

contains(Object Character) → bool
Whether Character is an element of this sequence of characters. [...]
containsAll(Characters other) → bool
Whether this sequence of characters contains other as a subsequence.
endsWith(Characters other) → bool
Whether this string ends with the characters of other. [...]
findFirst(Characters characters) CharacterRange
Finds the first occurrence of characters in this string. [...]
findLast(Characters characters) CharacterRange
Finds the last occurrence of characters. [...]
replaceAll(Characters pattern, Characters replacement) Characters
Replaces pattern with replacement. [...]
replaceFirst(Characters pattern, Characters replacement) Characters
Replaces the first occurrence of pattern with replacement. [...]
skip(int count) Characters
Eagerly selects all but the first count characters. [...]
skipLast(int count) Characters
Eagerly selects all but the last count characters. [...]
skipLastWhile(bool test(String)) Characters
Eagerly selects a leading sequnce of characters. [...]
skipWhile(bool test(String)) Characters
Eagerly selects a trailing sequence of characters. [...]
startsWith(Characters other) → bool
Whether this string starts with the characters of other. [...]
take(int count) Characters
Eagerly selects the first count characters. [...]
takeLast(int count) Characters
Eagerly selects the last count characters. [...]
takeLastWhile(bool test(String)) Characters
Eagerly selects a trailing sequence of characters. [...]
takeWhile(bool test(String)) Characters
Eagerly selects a leading sequnce of characters. [...]
toLowerCase() Characters
The characters of the lower-case version of string.
toString() → String
The string content of these characters.
toUpperCase() Characters
The characters of the upper-case version of string.
where(bool test(String)) Characters
Eagerly selects a subset of the characters. [...]
any(bool test(String element)) → bool
Checks whether any element of this iterable satisfies test.
inherited
cast<R>() → Iterable<R>
Provides a view of this iterable as an iterable of R instances.
inherited
elementAt(int index) → String
Returns the indexth element.
inherited
every(bool test(String element)) → bool
Checks whether every element of this iterable satisfies test.
inherited
expand<T>(Iterable<T> f(String element)) → Iterable<T>
Expands each element of this Iterable into zero or more elements.
inherited
firstWhere(bool test(String element), {String orElse()}) → String
Returns the first element that satisfies the given predicate test.
inherited
fold<T>(T initialValue, T combine(T previousValue, String element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(Iterable<String> other) → Iterable<String>
Returns the lazy concatentation of this iterable and other.
inherited
forEach(void f(String element)) → void
Applies the function f to each element of this collection in iteration order.
inherited
join([String separator = ""]) → String
Converts each element to a String and concatenates the strings.
inherited
lastWhere(bool test(String element), {String orElse()}) → String
Returns the last element that satisfies the given predicate test.
inherited
map<T>(T f(String e)) → Iterable<T>
Returns a new lazy Iterable with elements that are created by calling f on each element of this Iterable in iteration order.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
reduce(String combine(String value, String element)) → String
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
singleWhere(bool test(String element), {String orElse()}) → String
Returns the single element that satisfies test.
inherited
toList({bool growable: true}) → List<String>
Creates a List containing the elements of this Iterable.
inherited
toSet() → Set<String>
Creates a Set containing the same elements as this iterable.
inherited
whereType<T>() → Iterable<T>
Returns a new lazy Iterable with all elements that have type T.
inherited

Operators

operator +(Characters other) Characters
The characters of the concatenation of this and other. [...]
operator ==(Object other) → bool
Whether other to another Characters with the same string.