Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/icu/text/UnicodeSet#nestedclasses) \| [Constants](https://developer.android.com/reference/android/icu/text/UnicodeSet#constants) \| [Inherited Constants](https://developer.android.com/reference/android/icu/text/UnicodeSet#inhconstants) \| [Fields](https://developer.android.com/reference/android/icu/text/UnicodeSet#lfields) \| [Ctors](https://developer.android.com/reference/android/icu/text/UnicodeSet#pubctors) \| [Methods](https://developer.android.com/reference/android/icu/text/UnicodeSet#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/icu/text/UnicodeSet#inhmethods)

# UnicodeSet

*** ** * ** ***

` public class UnicodeSet `   
` ` ` extends https://developer.android.com/reference/android/icu/text/UnicodeFilter ` ` implements https://developer.android.com/reference/java/lang/Comparable<https://developer.android.com/reference/android/icu/text/UnicodeSet>, https://developer.android.com/reference/android/icu/util/Freezable<https://developer.android.com/reference/android/icu/text/UnicodeSet>, https://developer.android.com/reference/java/lang/Iterable<https://developer.android.com/reference/java/lang/String> `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.icu.text.UnicodeFilter](https://developer.android.com/reference/android/icu/text/UnicodeFilter) ||
|   | ↳ | android.icu.text.UnicodeSet |

<br />

*** ** * ** ***

A mutable set of Unicode characters and multicharacter strings. Objects of this class represent *character classes* used in regular expressions. A character specifies a subset of Unicode code points. Legal code points are U+0000 to U+10FFFF, inclusive. Note: method freeze() will not only make the set immutable, but also makes important methods much higher performance: contains(c), containsNone(...), span(...), spanBack(...) etc. After the object is frozen, any subsequent call that wants to change the object will throw UnsupportedOperationException.

The UnicodeSet class is not designed to be subclassed.

`UnicodeSet` supports two APIs. The first is the *operand* API that allows the caller to modify the value of a `UnicodeSet` object. It conforms to Java 2's `java.util.Set` interface, although `UnicodeSet` does not actually implement that interface. All methods of `Set` are supported, with the modification that they take a character range or single character instead of an `Object`, and they take a `UnicodeSet` instead of a `Collection`. The operand API may be thought of in terms of boolean logic: a boolean OR is implemented by `add`, a boolean AND is implemented by `retain`, a boolean XOR is implemented by `complement` taking an argument, and a boolean NOT is implemented by `complement` with no argument. In terms of traditional set theory function names, `add` is a union, `retain` is an intersection, `remove` is an asymmetric difference, and `complement` with no argument is a set complement with respect to the superset range `MIN_VALUE-MAX_VALUE`

The second API is the `applyPattern()`/`toPattern()` API from the `java.text.Format`-derived classes. Unlike the methods that add characters, add categories, and control the logic of the set, the method `applyPattern()` sets all attributes of a `UnicodeSet` at once, based on a string pattern.

**Pattern syntax**
Patterns are accepted by the constructors and the `applyPattern()` methods and returned by the `toPattern()` method. These patterns follow a syntax similar to that employed by version 8 regular expression character classes. Here are some simple examples:
>
> |---|---|
> | `[]` | No characters |
> | `[a]` | The character 'a' |
> | `[ae]` | The characters 'a' and 'e' |
> | `[a-e]` | The characters 'a' through 'e' inclusive, in Unicode code point order |
> | `[\\u4E01]` | The character U+4E01 |
> | `[a{ab}{ac}]` | The character 'a' and the multicharacter strings "ab" and "ac" |
> | `[\p{Lu}]` | All characters in the general category Uppercase Letter |

Any character may be preceded by a backslash in order to remove any special meaning. White space characters, as defined by the Unicode Pattern_White_Space property, are ignored, unless they are escaped.

Property patterns specify a set of characters having a certain property as defined by the Unicode standard. Both the POSIX-like "\[:Lu:\]" and the Perl-like syntax "\\p{Lu}" are recognized. For a complete list of supported property patterns, see the User's Guide for UnicodeSet at <https://unicode-org.github.io/icu/userguide/strings/unicodeset>. Actual determination of property data is defined by the underlying Unicode database as implemented by UCharacter.

Patterns specify individual characters, ranges of characters, and Unicode property sets. When elements are concatenated, they specify their union. To complement a set, place a '\^' immediately after the opening '\['. Property patterns are inverted by modifying their delimiters; "\[:\^foo\]" and "\\P{foo}". In any other location, '\^' has no special meaning.

Since ICU 70, "\[\^...\]", "\[:\^foo\]", "\\P{foo}", and "\[:binaryProperty=No:\]" perform a \\u201ccode point complement\\u201d (all code points minus the original set), removing all multicharacter strings, equivalent to .`https://developer.android.com/reference/android/icu/text/UnicodeSet#complement()`.`https://developer.android.com/reference/android/icu/text/UnicodeSet#removeAllStrings()` . The `https://developer.android.com/reference/android/icu/text/UnicodeSet#complement()` API function continues to perform a symmetric difference with all code points and thus retains all multicharacter strings.

Ranges are indicated by placing two a '-' between two characters, as in "a-z". This specifies the range of all characters from the left to the right, in Unicode order. If the left character is greater than or equal to the right character it is a syntax error. If a '-' occurs as the first character after the opening '\[' or '\[\^', or if it occurs as the last character before the closing '\]', then it is taken as a literal. Thus "\[a\\\\-b\]", "\[-ab\]", and "\[ab-\]" all indicate the same set of three characters, 'a', 'b', and '-'.

Sets may be intersected using the '\&' operator or the asymmetric set difference may be taken using the '-' operator, for example, "\[\[:L:\]\&\[\\\\u0000-\\\\u0FFF\]\]" indicates the set of all Unicode letters with values less than 4096. Operators ('\&' and '\|') have equal precedence and bind left-to-right. Thus "\[\[:L:\]-\[a-z\]-\[\\\\u0100-\\\\u01FF\]\]" is equivalent to "\[\[\[:L:\]-\[a-z\]\]-\[\\\\u0100-\\\\u01FF\]\]". This only really matters for difference; intersection is commutative.

|---|---|
| `[a]` | The set containing 'a' |
| `[a-z]` | The set containing 'a' through 'z' and all letters in between, in Unicode order |
| `[^a-z]` | The set containing all characters but 'a' through 'z', that is, U+0000 through 'a'-1 and 'z'+1 through U+10FFFF |
| `[[pat1][pat2]]` | The union of sets specified by *pat1* and *pat2* |
| `[[pat1]&[pat2]]` | The intersection of sets specified by *pat1* and *pat2* |
| `[[pat1]-[pat2]]` | The asymmetric difference of sets specified by *pat1* and *pat2* |
| `[:Lu:] or \p{Lu}` | The set of characters having the specified Unicode property; in this case, Unicode uppercase letters |
| `[:^Lu:] or \P{Lu}` | The set of characters *not* having the given Unicode property |

**Formal syntax**
>
> |---|---|
> | `pattern := ` | `('[' '^'? item* ']') | property` |
> | `item := ` | `char | (char '-' char) | pattern-expr ` |
> | `pattern-expr := ` | `pattern | pattern-expr pattern | pattern-expr op pattern ` |
> | `op := ` | `'&' | '-' ` |
> | `special := ` | `'[' | ']' | '-' ` |
> | `char := ` | *any character that is not* ` special | ('\\' `*any character* `) | ('\u' hex hex hex hex) ` |
> | `hex := ` | `'0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'` |
> | `property := ` | *a Unicode property set pattern* |
>
> <br />
>
> Legend: `a := b` `a` may be replaced by `b` `a?` zero or one instance of `a`  
> `a*` one or more instances of `a`  
> `a | b` either `a` or `b`  
> `'a'` the literal string between the quotes

To iterate over contents of `UnicodeSet`, the following are available:

- to iterate over the ranges: `https://developer.android.com/reference/android/icu/text/UnicodeSet#ranges()`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#rangeStream()`
- to iterate over the strings: `https://developer.android.com/reference/android/icu/text/UnicodeSet#strings()`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#stringStream()`
- to iterate over the code points: `https://developer.android.com/reference/android/icu/text/UnicodeSet#codePoints()`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#codePointStream()`
- to iterate over the entire contents in a single loop: this class itself is `https://developer.android.com/reference/java/lang/Iterable`, or use `https://developer.android.com/reference/android/icu/text/UnicodeSet#stream()`.  
  All of these method are, however, not particularly efficient, since they convert each individual code point to a `String`.

The iterators and streams methods work as expected in idiomatic Java usage.  

The `https://developer.android.com/reference/android/icu/text/UnicodeSetIterator` cannot be used in **for** loops, and it is not very Java-idiomatic, because it is old. But it might be faster in certain use cases. We recommend that you measure in performance sensitive code.  

To replace, count elements, or delete spans, see `https://developer.android.com/reference/android/icu/text/UnicodeSetSpanner`.
**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSetIterator`
- `https://developer.android.com/reference/android/icu/text/UnicodeSetSpanner`

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange` A struct-like class used for iteration through ranges, for faster iteration than by String. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#ADD_CASE_MAPPINGS` Adds all case mappings for each element in the set. |
| `int` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE` *This constant was deprecated in API level 35. ICU 73 Use `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE` instead.* |
| `int` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE` Enable case insensitive matching. |
| `int` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#IGNORE_SPACE` Bitmask for constructor and applyPattern() indicating that white space should be ignored. |
| `int` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#MAX_VALUE` Maximum value that can be stored in a UnicodeSet. |
| `int` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#MIN_VALUE` Minimum value that can be stored in a UnicodeSet. |
| `int` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#SIMPLE_CASE_INSENSITIVE` Enable case insensitive matching. |

### Inherited constants

From interface `https://developer.android.com/reference/android/icu/text/UnicodeMatcher` `char` `https://developer.android.com/reference/android/icu/text/UnicodeMatcher#ETHER`

The character at index i, where i \< contextStart \|\| i \>= contextLimit, is ETHER.
`int` `https://developer.android.com/reference/android/icu/text/UnicodeMatcher#U_MATCH`

Constant returned by `matches()` indicating a complete match between the text and this matcher.
`int` `https://developer.android.com/reference/android/icu/text/UnicodeMatcher#U_MISMATCH`

Constant returned by `matches()` indicating a mismatch between the text and this matcher.
`int` `https://developer.android.com/reference/android/icu/text/UnicodeMatcher#U_PARTIAL_MATCH`

Constant returned by `matches()` indicating a partial match between the text and this matcher.

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/icu/text/UnicodeSet` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#ALL_CODE_POINTS` Constant for the set of all code points. |
| ` public static final https://developer.android.com/reference/android/icu/text/UnicodeSet` | `https://developer.android.com/reference/android/icu/text/UnicodeSet#EMPTY` Constant for the empty set. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet()() ` Constructs an empty set. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet other) ` Constructs a copy of an existing set. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet(int,%20int)(int start, int end) ` Constructs a set containing the given range. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet(int[])(int... pairs) ` Quickly constructs a set from a set of ranges \<s0, e0, s1, e1, s2, e2, ..., sn, en\>. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet(java.lang.String)(https://developer.android.com/reference/java/lang/String pattern) ` Constructs a set from the given pattern. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String pattern, boolean ignoreWhitespace) ` Constructs a set from the given pattern. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String pattern, int options) ` Constructs a set from the given pattern. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet(java.lang.String,%20java.text.ParsePosition,%20android.icu.text.SymbolTable)(https://developer.android.com/reference/java/lang/String pattern, https://developer.android.com/reference/java/text/ParsePosition pos, https://developer.android.com/reference/android/icu/text/SymbolTable symbols) ` Constructs a set from the given pattern. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet#UnicodeSet(java.lang.String,%20java.text.ParsePosition,%20android.icu.text.SymbolTable,%20int)(https://developer.android.com/reference/java/lang/String pattern, https://developer.android.com/reference/java/text/ParsePosition pos, https://developer.android.com/reference/android/icu/text/SymbolTable symbols, int options) ` Constructs a set from the given pattern. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/StringBuffer` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#_generatePattern(java.lang.StringBuffer,%20boolean)(https://developer.android.com/reference/java/lang/StringBuffer result, boolean escapeUnprintable) ` Generate and append a string representation of this set to result. |
| ` https://developer.android.com/reference/java/lang/StringBuffer` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#_generatePattern(java.lang.StringBuffer,%20boolean,%20boolean)(https://developer.android.com/reference/java/lang/StringBuffer result, boolean escapeUnprintable, boolean includeStrings) ` Generate and append a string representation of this set to result. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#add(int)(int c) ` Adds the specified character to this set if it is not already present. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#add(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Adds the specified multicharacter to this set if it is not already present. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#add(java.lang.Iterable<?>)(https://developer.android.com/reference/java/lang/Iterable<?> source) ` Add the contents of the collection (as strings) into this UnicodeSet. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#add(int,%20int)(int start, int end) ` Adds the specified range to this set if it is not already present. |
| ` <T extends https://developer.android.com/reference/java/lang/CharSequence> https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#addAll(T[])(T... collection) ` |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#addAll(int,%20int)(int start, int end) ` Adds all characters in range (uses preferred naming convention). |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#addAll(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet c) ` Adds all of the elements in the specified set to this set if they're not already present. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#addAll(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Adds each of the characters in this string to the set. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#addAll(java.lang.Iterable<?>)(https://developer.android.com/reference/java/lang/Iterable<?> source) ` Add a collection (as strings) into this UnicodeSet. |
| ` <T extends https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/java/lang/String>> T` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#addAllTo(T)(T target) ` Add the contents of the UnicodeSet (as strings) into a collection. |
| ` void` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#addMatchSetTo(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet toUnionTo) ` Implementation of UnicodeMatcher API. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#applyIntPropertyValue(int,%20int)(int prop, int value) ` Modifies this set to contain those code points which have the given value for the given binary or enumerated property, as returned by UCharacter.getIntPropertyValue. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#applyPattern(java.lang.String)(https://developer.android.com/reference/java/lang/String pattern) ` Modifies this set to represent the set specified by the given pattern. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#applyPattern(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String pattern, int options) ` Modifies this set to represent the set specified by the given pattern, optionally ignoring whitespace. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#applyPattern(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String pattern, boolean ignoreWhitespace) ` Modifies this set to represent the set specified by the given pattern, optionally ignoring whitespace. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#applyPropertyAlias(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String propertyAlias, https://developer.android.com/reference/java/lang/String valueAlias) ` Modifies this set to contain those code points which have the given value for the given property. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#applyPropertyAlias(java.lang.String,%20java.lang.String,%20android.icu.text.SymbolTable)(https://developer.android.com/reference/java/lang/String propertyAlias, https://developer.android.com/reference/java/lang/String valueAlias, https://developer.android.com/reference/android/icu/text/SymbolTable symbols) ` Modifies this set to contain those code points which have the given value for the given property. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#charAt(int)(int index) ` Returns the character at the given index within this set, where the set is ordered by ascending code point. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#clear()() ` Removes all of the elements from this set. |
| ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#clone()() ` Return a new set that is equivalent to this one. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#cloneAsThawed()() ` Clone a thawed version of this class, according to the Freezable interface. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#closeOver(int)(int attribute) ` Close this set over the given attribute. |
| ` https://developer.android.com/reference/java/util/stream/IntStream` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#codePointStream()() ` Returns an `https://developer.android.com/reference/java/util/stream/IntStream` of Unicode code point values from this `UnicodeSet`. |
| ` https://developer.android.com/reference/java/lang/Iterable<https://developer.android.com/reference/java/lang/Integer>` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#codePoints()() ` Returns an `https://developer.android.com/reference/java/lang/Iterable` for iteration over all the code points in this set. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#compact()() ` Reallocate this objects internal structures to take up the least possible space, without changing this object's value. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#compareTo(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet o) ` Compares UnicodeSets, where shorter come first, and otherwise lexicographically (according to the comparison of the first characters that differ). |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#compareTo(android.icu.text.UnicodeSet,%20android.icu.text.UnicodeSet.ComparisonStyle)(https://developer.android.com/reference/android/icu/text/UnicodeSet o, https://developer.android.com/reference/android/icu/text/UnicodeSet.ComparisonStyle style) ` Compares UnicodeSets, in three different ways. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#compareTo(java.lang.Iterable<java.lang.String>)(https://developer.android.com/reference/java/lang/Iterable<https://developer.android.com/reference/java/lang/String> other) ` |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#complement(int,%20int)(int start, int end) ` Complements the specified range in this set. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#complement()() ` This is equivalent to `complement(MIN_VALUE, MAX_VALUE)`. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#complement(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Complement the specified string in this set. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#complement(int)(int c) ` Complements the specified character in this set. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#complementAll(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Complement EACH of the characters in this string. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#complementAll(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet c) ` Complements in this set all elements contained in the specified set. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#contains(int)(int c) ` Returns true if this set contains the given character. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#contains(int,%20int)(int start, int end) ` Returns true if this set contains every character of the given range. |
| ` final boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#contains(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Returns `true` if this set contains the given multicharacter string. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsAll(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet b) ` Returns true if this set contains all the characters and strings of the given set. |
| ` <T extends https://developer.android.com/reference/java/lang/CharSequence> boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsAll(java.lang.Iterable<T>)(https://developer.android.com/reference/java/lang/Iterable<T> collection) ` |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsAll(java.lang.String)(https://developer.android.com/reference/java/lang/String s) ` Returns true if there is a partition of the string such that this set contains each of the partitioned strings. |
| ` <T extends https://developer.android.com/reference/java/lang/CharSequence> boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsNone(java.lang.Iterable<T>)(https://developer.android.com/reference/java/lang/Iterable<T> collection) ` |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsNone(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet b) ` Returns true if none of the characters or strings in this UnicodeSet appears in the string. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsNone(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Returns true if this set contains none of the characters of the given string. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsNone(int,%20int)(int start, int end) ` Returns true if this set contains none of the characters of the given range. |
| ` final boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsSome(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet s) ` Returns true if this set contains one or more of the characters and strings of the given set. |
| ` final boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsSome(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Returns true if this set contains one or more of the characters of the given string. |
| ` final <T extends https://developer.android.com/reference/java/lang/CharSequence> boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsSome(java.lang.Iterable<T>)(https://developer.android.com/reference/java/lang/Iterable<T> collection) ` |
| ` final boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#containsSome(int,%20int)(int start, int end) ` Returns true if this set contains one or more of the characters in the given range. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` Compares the specified object with this set for equality. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#freeze()() ` Freeze this class, according to the Freezable interface. |
| ` static https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#from(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Makes a set from a multicharacter string. |
| ` static https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#fromAll(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Makes a set from each of the characters in the string. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeCount()() ` Iteration method that returns the number of ranges contained in this set. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeEnd(int)(int index) ` Iteration method that returns the last character in the specified range of this set. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeStart(int)(int index) ` Iteration method that returns the first character in the specified range of this set. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#hasStrings()() ` |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#hashCode()() ` Returns the hash code value for this set. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#indexOf(int)(int c) ` Returns the index of the given character within this set, where the set is ordered by ascending code point. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#isEmpty()() ` Returns `true` if this set contains no elements. |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#isFrozen()() ` Is this frozen, according to the Freezable interface? |
| ` https://developer.android.com/reference/java/util/Iterator<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#iterator()() ` Returns a string iterator. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#matches(android.icu.text.Replaceable,%20int[],%20int,%20boolean)(https://developer.android.com/reference/android/icu/text/Replaceable text, int[] offset, int limit, boolean incremental) ` Implementation of UnicodeMatcher.matches(). |
| ` boolean` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#matchesIndexValue(int)(int v) ` Implementation of UnicodeMatcher API. |
| ` https://developer.android.com/reference/java/util/stream/Stream<https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange>` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#rangeStream()() ` Returns a `https://developer.android.com/reference/java/util/stream/Stream` of `https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange` values from this `UnicodeSet`. |
| ` https://developer.android.com/reference/java/lang/Iterable<https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange>` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#ranges()() ` Provide for faster iteration than by String. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#remove(int,%20int)(int start, int end) ` Removes the specified range from this set if it is present. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#remove(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Removes the specified string from this set if it is present. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#remove(int)(int c) ` Removes the specified character from this set if it is present. |
| ` <T extends https://developer.android.com/reference/java/lang/CharSequence> https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#removeAll(java.lang.Iterable<T>)(https://developer.android.com/reference/java/lang/Iterable<T> collection) ` |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#removeAll(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet c) ` Removes from this set all of its elements that are contained in the specified set. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#removeAll(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Remove EACH of the characters in this string. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#removeAllStrings()() ` Remove all strings from this UnicodeSet |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#retain(int,%20int)(int start, int end) ` Retain only the elements in this set that are contained in the specified range. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#retain(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence cs) ` Retain the specified string in this set if it is present. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#retain(int)(int c) ` Retain the specified character from this set if it is present. |
| ` final https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#retainAll(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence s) ` Retains EACH of the characters in this string. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#retainAll(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet c) ` Retains only the elements in this set that are contained in the specified set. |
| ` <T extends https://developer.android.com/reference/java/lang/CharSequence> https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#retainAll(java.lang.Iterable<T>)(https://developer.android.com/reference/java/lang/Iterable<T> collection) ` |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#set(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet other) ` Make this object represent the same set as `other`. |
| ` https://developer.android.com/reference/android/icu/text/UnicodeSet` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#set(int,%20int)(int start, int end) ` Make this object represent the range `start - end`. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#size()() ` Returns the number of elements in this set (its cardinality) Note than the elements of a set may include both individual codepoints and strings. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#span(java.lang.CharSequence,%20int,%20android.icu.text.UnicodeSet.SpanCondition)(https://developer.android.com/reference/java/lang/CharSequence s, int start, https://developer.android.com/reference/android/icu/text/UnicodeSet.SpanCondition spanCondition) ` Span a string using this UnicodeSet. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#span(java.lang.CharSequence,%20android.icu.text.UnicodeSet.SpanCondition)(https://developer.android.com/reference/java/lang/CharSequence s, https://developer.android.com/reference/android/icu/text/UnicodeSet.SpanCondition spanCondition) ` Span a string using this UnicodeSet. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#spanBack(java.lang.CharSequence,%20android.icu.text.UnicodeSet.SpanCondition)(https://developer.android.com/reference/java/lang/CharSequence s, https://developer.android.com/reference/android/icu/text/UnicodeSet.SpanCondition spanCondition) ` Span a string backwards (from the end) using this UnicodeSet. |
| ` int` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#spanBack(java.lang.CharSequence,%20int,%20android.icu.text.UnicodeSet.SpanCondition)(https://developer.android.com/reference/java/lang/CharSequence s, int fromIndex, https://developer.android.com/reference/android/icu/text/UnicodeSet.SpanCondition spanCondition) ` Span a string backwards (from the fromIndex) using this UnicodeSet. |
| ` https://developer.android.com/reference/java/util/stream/Stream<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#stream()() ` Returns a stream of `String` values from this `UnicodeSet`. |
| ` https://developer.android.com/reference/java/util/stream/Stream<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#stringStream()() ` Returns a `https://developer.android.com/reference/java/util/stream/Stream` of `String` values from this `UnicodeSet`. |
| ` https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#strings()() ` For iterating through the strings in the set. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#toPattern(boolean)(boolean escapeUnprintable) ` Returns a string representation of this set. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/icu/text/UnicodeSet#toString()() ` Return a programmer-readable string representation of this object. |

### Inherited methods

From class ` https://developer.android.com/reference/android/icu/text/UnicodeFilter ` ` abstract boolean` ` https://developer.android.com/reference/android/icu/text/UnicodeFilter#contains(int)(int c) `

Returns `true` for characters that are in the selected subset.
` int` ` https://developer.android.com/reference/android/icu/text/UnicodeFilter#matches(android.icu.text.Replaceable,%20int[],%20int,%20boolean)(https://developer.android.com/reference/android/icu/text/Replaceable text, int[] offset, int limit, boolean incremental) `

Default implementation of UnicodeMatcher::matches() for Unicode filters.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/icu/text/UnicodeMatcher ` ` abstract void` ` https://developer.android.com/reference/android/icu/text/UnicodeMatcher#addMatchSetTo(android.icu.text.UnicodeSet)(https://developer.android.com/reference/android/icu/text/UnicodeSet toUnionTo) `

Union the set of all characters that may be matched by this object into the given set.
` abstract int` ` https://developer.android.com/reference/android/icu/text/UnicodeMatcher#matches(android.icu.text.Replaceable,%20int[],%20int,%20boolean)(https://developer.android.com/reference/android/icu/text/Replaceable text, int[] offset, int limit, boolean incremental) `

Return a UMatchDegree value indicating the degree of match for the given text at the given offset.
` abstract boolean` ` https://developer.android.com/reference/android/icu/text/UnicodeMatcher#matchesIndexValue(int)(int v) `

Returns true if this matcher will match a character c, where c \& 0xFF == v, at offset, in the forward direction (with limit \> offset).
` abstract https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/android/icu/text/UnicodeMatcher#toPattern(boolean)(boolean escapeUnprintable) `

Returns a string representation of this matcher.
From interface ` https://developer.android.com/reference/java/lang/Comparable ` ` abstract int` ` https://developer.android.com/reference/java/lang/Comparable#compareTo(T)(https://developer.android.com/reference/android/icu/text/UnicodeSet o) `

Compares this object with the specified object for order.
From interface ` https://developer.android.com/reference/android/icu/util/Freezable ` ` abstract https://developer.android.com/reference/android/icu/text/UnicodeSet` ` https://developer.android.com/reference/android/icu/util/Freezable#cloneAsThawed()() `

Provides for the clone operation.
` abstract https://developer.android.com/reference/android/icu/text/UnicodeSet` ` https://developer.android.com/reference/android/icu/util/Freezable#freeze()() `

Freezes the object.
` abstract boolean` ` https://developer.android.com/reference/android/icu/util/Freezable#isFrozen()() `

Determines whether the object has been frozen or not.
From interface ` https://developer.android.com/reference/java/lang/Iterable ` ` default void` ` https://developer.android.com/reference/java/lang/Iterable#forEach(java.util.function.Consumer<?%20super%20T>)(https://developer.android.com/reference/java/util/function/Consumer<? super T> action) `

Performs the given action for each element of the `Iterable` until all elements have been processed or the action throws an exception.
` abstract https://developer.android.com/reference/java/util/Iterator<https://developer.android.com/reference/java/lang/String>` ` https://developer.android.com/reference/java/lang/Iterable#iterator()() `

Returns an iterator over elements of type `T`.
` default https://developer.android.com/reference/java/util/Spliterator<https://developer.android.com/reference/java/lang/String>` ` https://developer.android.com/reference/java/lang/Iterable#spliterator()() `

Creates a `https://developer.android.com/reference/java/util/Spliterator` over the elements described by this `Iterable`.

## Constants

### ADD_CASE_MAPPINGS

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ADD_CASE_MAPPINGS
```

Adds all case mappings for each element in the set. This adds the full lower-, title-, and uppercase mappings as well as the full case folding of each existing element in the set.

This value is an options bit set value for some constructors, applyPattern(), and closeOver(). It can be ORed together with other, unrelated options.

Unlike the \\u201ccase insensitive\\u201d options, this does not perform a closure. For example, it does not add '\\u017f' (U+017F long s) for 's', 'K' (U+212A Kelvin sign) for 'k', or replace set strings by their case-folded versions.

<br />

Constant Value: 4 (0x00000004)

### CASE

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int CASE
```

<br />

**This constant was deprecated in API level 35.**   

ICU 73 Use `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE` instead.

Alias for `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE`.

<br />

Constant Value: 2 (0x00000002)

### CASE_INSENSITIVE

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int CASE_INSENSITIVE
```

Enable case insensitive matching. E.g., "\[ab\]" with this flag will match 'a', 'A', 'b', and 'B'. "\[\^ab\]" with this flag will match all except 'a', 'A', 'b', and 'B'. This performs a full closure over case mappings, e.g. '\\u017f' (U+017F long s) for 's'.

This value is an options bit set value for some constructors, applyPattern(), and closeOver(). It can be ORed together with other, unrelated options.

The resulting set is a superset of the input for the code points but not for the strings. It performs a case mapping closure of the code points and adds full case folding strings for the code points, and reduces strings of the original set to their full case folding equivalents.

This is designed for case-insensitive matches, for example in regular expressions. The full code point case closure allows checking of an input character directly against the closure set. Strings are matched by comparing the case-folded form from the closure set with an incremental case folding of the string in question.

The closure set will also contain single code points if the original set contained case-equivalent strings (like U+00DF for "ss" or "Ss" etc.). This is not necessary (that is, redundant) for the above matching method but results in the same closure sets regardless of whether the original set contained the code point or a string.

<br />

Constant Value: 2 (0x00000002)

### IGNORE_SPACE

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int IGNORE_SPACE
```

Bitmask for constructor and applyPattern() indicating that white space should be ignored. If set, ignore Unicode Pattern_White_Space characters, unless they are quoted or escaped. This may be ORed together with other selectors.

<br />

Constant Value: 1 (0x00000001)

### MAX_VALUE

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MAX_VALUE
```

Maximum value that can be stored in a UnicodeSet.

<br />

Constant Value: 1114111 (0x0010ffff)

### MIN_VALUE

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MIN_VALUE
```

Minimum value that can be stored in a UnicodeSet.

<br />

Constant Value: 0 (0x00000000)

### SIMPLE_CASE_INSENSITIVE

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SIMPLE_CASE_INSENSITIVE
```

Enable case insensitive matching. Same as `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE` but using only Simple_Case_Folding (scf) mappings, which map each code point to one code point, not full Case_Folding (cf) mappings, which map some code points to multiple code points.

This is designed for case-insensitive matches, for example in certain regular expression implementations where only Simple_Case_Folding mappings are used, such as in ECMAScript (JavaScript) regular expressions.

This value is an options bit set value for some constructors, applyPattern(), and closeOver(). It can be ORed together with other, unrelated options.

<br />

Constant Value: 6 (0x00000006)

## Fields

### ALL_CODE_POINTS

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UnicodeSet ALL_CODE_POINTS
```

Constant for the set of all code points. (Since UnicodeSets can include strings, does not include everything that a UnicodeSet can.)

<br />

### EMPTY

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UnicodeSet EMPTY
```

Constant for the empty set.

<br />

## Public constructors

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet ()
```

Constructs an empty set.

<br />

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet (UnicodeSet other)
```

Constructs a copy of an existing set.

<br />

| Parameters ||
|---|---|
| `other` | `UnicodeSet` <br /> |

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet (int start, 
                int end)
```

Constructs a set containing the given range. If `end > start` then an empty set is created.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character, inclusive, of range <br /> |
| `end` | `int`: last character, inclusive, of range <br /> |

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet (int... pairs)
```

Quickly constructs a set from a set of ranges \<s0, e0, s1, e1, s2, e2, ..., sn, en\>. There must be an even number of integers, and they must be all greater than zero, all less than or equal to Character.MAX_CODE_POINT. In each pair (..., si, ei, ...) it must be true that si \<= ei Between adjacent pairs (...ei, sj...), it must be true that ei+1 \< sj

<br />

| Parameters ||
|---|---|
| `pairs` | `int`: pairs of character representing ranges <br /> |

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet (String pattern)
```

Constructs a set from the given pattern. See the class description for the syntax of the pattern language. Whitespace is ignored.

<br />

| Parameters ||
|---|---|
| `pattern` | `String`: a string specifying what characters are in the set <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the pattern contains a syntax error. |

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet (String pattern, 
                boolean ignoreWhitespace)
```

Constructs a set from the given pattern. See the class description for the syntax of the pattern language.

<br />

| Parameters ||
|---|---|
| `pattern` | `String`: a string specifying what characters are in the set <br /> |
| `ignoreWhitespace` | `boolean`: if true, ignore Unicode Pattern_White_Space characters <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the pattern contains a syntax error. |

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet (String pattern, 
                int options)
```

Constructs a set from the given pattern. See the class description for the syntax of the pattern language.

<br />

| Parameters ||
|---|---|
| `pattern` | `String`: a string specifying what characters are in the set <br /> |
| `options` | `int`: a bitmask indicating which options to apply. Valid options are `https://developer.android.com/reference/android/icu/text/UnicodeSet#IGNORE_SPACE` and at most one of `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#ADD_CASE_MAPPINGS`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#SIMPLE_CASE_INSENSITIVE`. These case options are mutually exclusive. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the pattern contains a syntax error. |

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet (String pattern, 
                ParsePosition pos, 
                SymbolTable symbols)
```

Constructs a set from the given pattern. See the class description for the syntax of the pattern language.

<br />

| Parameters ||
|---|---|
| `pattern` | `String`: a string specifying what characters are in the set <br /> |
| `pos` | `ParsePosition`: on input, the position in pattern at which to start parsing. On output, the position after the last character parsed. <br /> |
| `symbols` | `SymbolTable`: a symbol table mapping variables to char\[\] arrays and chars to UnicodeSets <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the pattern contains a syntax error. |

### UnicodeSet

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet (String pattern, 
                ParsePosition pos, 
                SymbolTable symbols, 
                int options)
```

Constructs a set from the given pattern. See the class description for the syntax of the pattern language.

<br />

| Parameters ||
|---|---|
| `pattern` | `String`: a string specifying what characters are in the set <br /> |
| `pos` | `ParsePosition`: on input, the position in pattern at which to start parsing. On output, the position after the last character parsed. <br /> |
| `symbols` | `SymbolTable`: a symbol table mapping variables to char\[\] arrays and chars to UnicodeSets <br /> |
| `options` | `int`: a bitmask indicating which options to apply. Valid options are `https://developer.android.com/reference/android/icu/text/UnicodeSet#IGNORE_SPACE` and at most one of `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#ADD_CASE_MAPPINGS`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#SIMPLE_CASE_INSENSITIVE`. These case options are mutually exclusive. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the pattern contains a syntax error. |

## Public methods

### _generatePattern

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuffer _generatePattern (StringBuffer result, 
                boolean escapeUnprintable)
```

Generate and append a string representation of this set to result. This does not use this.pat, the cleaned up copy of the string passed to applyPattern().

<br />

| Parameters ||
|---|---|
| `result` | `StringBuffer`: the buffer into which to generate the pattern <br /> |
| `escapeUnprintable` | `boolean`: escape unprintable characters if true <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuffer` | <br /> |

### _generatePattern

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StringBuffer _generatePattern (StringBuffer result, 
                boolean escapeUnprintable, 
                boolean includeStrings)
```

Generate and append a string representation of this set to result. This does not use this.pat, the cleaned up copy of the string passed to applyPattern().

<br />

| Parameters ||
|---|---|
| `result` | `StringBuffer`: the buffer into which to generate the pattern <br /> |
| `escapeUnprintable` | `boolean`: escape unprintable characters if true <br /> |
| `includeStrings` | `boolean`: if false, doesn't include the strings. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuffer` | <br /> |

### add

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet add (int c)
```

Adds the specified character to this set if it is not already present. If this set already contains the specified character, the call leaves this set unchanged.

<br />

| Parameters ||
|---|---|
| `c` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### add

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet add (CharSequence s)
```

Adds the specified multicharacter to this set if it is not already present. If this set already contains the multicharacter, the call leaves this set unchanged. Thus "ch" =\> {"ch"}

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the source string <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### add

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet add (Iterable<?> source)
```

Add the contents of the collection (as strings) into this UnicodeSet. The collection must not contain null.

<br />

| Parameters ||
|---|---|
| `source` | `Iterable`: the collection to add <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | a reference to this object <br /> |

### add

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet add (int start, 
                int end)
```

Adds the specified range to this set if it is not already present. If this set already contains the specified range, the call leaves this set unchanged. If `start > end` then an empty range is added, leaving the set unchanged.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character, inclusive, of range to be added to this set. <br /> |
| `end` | `int`: last character, inclusive, of range to be added to this set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### addAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet addAll (T... collection)
```

<br />

<br />

| Parameters ||
|---|---|
| `collection` | `T` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#addAll(android.icu.text.UnicodeSet)`

### addAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet addAll (int start, 
                int end)
```

Adds all characters in range (uses preferred naming convention).

<br />

| Parameters ||
|---|---|
| `start` | `int`: The index of where to start on adding all characters. <br /> |
| `end` | `int`: The index of where to end on adding all characters. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | a reference to this object <br /> |

### addAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet addAll (UnicodeSet c)
```

Adds all of the elements in the specified set to this set if they're not already present. This operation effectively modifies this set so that its value is the *union* of the two sets. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress.

<br />

| Parameters ||
|---|---|
| `c` | `UnicodeSet`: set whose elements are to be added to this set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### addAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet addAll (CharSequence s)
```

Adds each of the characters in this string to the set. Thus "ch" =\> {"c", "h"} If this set already any particular character, it has no effect on that character.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the source string <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### addAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet addAll (Iterable<?> source)
```

Add a collection (as strings) into this UnicodeSet. Uses standard naming convention.

<br />

| Parameters ||
|---|---|
| `source` | `Iterable`: collection to add into <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | a reference to this object <br /> |

### addAllTo

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public T addAllTo (T target)
```

Add the contents of the UnicodeSet (as strings) into a collection.

<br />

| Parameters ||
|---|---|
| `target` | `T`: collection to add into <br /> |

| Returns ||
|---|---|
| `T` | <br /> |

### addMatchSetTo

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void addMatchSetTo (UnicodeSet toUnionTo)
```

Implementation of UnicodeMatcher API. Union the set of all characters that may be matched by this object into the given set.

<br />

| Parameters ||
|---|---|
| `toUnionTo` | `UnicodeSet`: the set into which to union the source characters <br /> |

### applyIntPropertyValue

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet applyIntPropertyValue (int prop, 
                int value)
```

Modifies this set to contain those code points which have the given value for the given binary or enumerated property, as returned by UCharacter.getIntPropertyValue. Prior contents of this set are lost.

<br />

| Parameters ||
|---|---|
| `prop` | `int`: a property in the range UProperty.BIN_START..UProperty.BIN_LIMIT-1 or UProperty.INT_START..UProperty.INT_LIMIT-1 or. UProperty.MASK_START..UProperty.MASK_LIMIT-1. <br /> |
| `value` | `int`: a value in the range UCharacter.getIntPropertyMinValue(prop).. UCharacter.getIntPropertyMaxValue(prop), with one exception. If prop is UProperty.GENERAL_CATEGORY_MASK, then value should not be a UCharacter.getType() result, but rather a mask value produced by logically ORing (1 \<\< UCharacter.getType()) values together. This allows grouped categories such as \[:L:\] to be represented. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | a reference to this set <br /> |

### applyPattern

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet applyPattern (String pattern)
```

Modifies this set to represent the set specified by the given pattern. See the class description for the syntax of the pattern language. Whitespace is ignored.

<br />

| Parameters ||
|---|---|
| `pattern` | `String`: a string specifying what characters are in the set <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the pattern contains a syntax error. |

### applyPattern

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet applyPattern (String pattern, 
                int options)
```

Modifies this set to represent the set specified by the given pattern, optionally ignoring whitespace. See the class description for the syntax of the pattern language.

<br />

| Parameters ||
|---|---|
| `pattern` | `String`: a string specifying what characters are in the set <br /> |
| `options` | `int`: a bitmask indicating which options to apply. Valid options are `https://developer.android.com/reference/android/icu/text/UnicodeSet#IGNORE_SPACE` and at most one of `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#ADD_CASE_MAPPINGS`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#SIMPLE_CASE_INSENSITIVE`. These case options are mutually exclusive. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the pattern contains a syntax error. |

### applyPattern

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet applyPattern (String pattern, 
                boolean ignoreWhitespace)
```

Modifies this set to represent the set specified by the given pattern, optionally ignoring whitespace. See the class description for the syntax of the pattern language.

<br />

| Parameters ||
|---|---|
| `pattern` | `String`: a string specifying what characters are in the set <br /> |
| `ignoreWhitespace` | `boolean`: if true then Unicode Pattern_White_Space characters are ignored <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the pattern contains a syntax error. |

### applyPropertyAlias

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet applyPropertyAlias (String propertyAlias, 
                String valueAlias)
```

Modifies this set to contain those code points which have the given value for the given property. Prior contents of this set are lost.

<br />

| Parameters ||
|---|---|
| `propertyAlias` | `String`: a property alias, either short or long. The name is matched loosely. See PropertyAliases.txt for names and a description of loose matching. If the value string is empty, then this string is interpreted as either a General_Category value alias, a Script value alias, a binary property alias, or a special ID. Special IDs are matched loosely and correspond to the following sets: "ANY" = \[\\\\u0000-\\\\U0010FFFF\], "ASCII" = \[\\\\u0000-\\\\u007F\]. <br /> |
| `valueAlias` | `String`: a value alias, either short or long. The name is matched loosely. See PropertyValueAliases.txt for names and a description of loose matching. In addition to aliases listed, numeric values and canonical combining classes may be expressed numerically, e.g., ("nv", "0.5") or ("ccc", "220"). The value string may also be empty. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | a reference to this set <br /> |

### applyPropertyAlias

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet applyPropertyAlias (String propertyAlias, 
                String valueAlias, 
                SymbolTable symbols)
```

Modifies this set to contain those code points which have the given value for the given property. Prior contents of this set are lost.

<br />

| Parameters ||
|---|---|
| `propertyAlias` | `String`: A string of the property alias. <br /> |
| `valueAlias` | `String`: A string of the value alias. <br /> |
| `symbols` | `SymbolTable`: if not null, then symbols are first called to see if a property is available. If true, then everything else is skipped. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this set <br /> |

### charAt

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int charAt (int index)
```

Returns the character at the given index within this set, where the set is ordered by ascending code point. If the index is out of range, return -1. The inverse of this method is `indexOf()`.

<br />

| Parameters ||
|---|---|
| `index` | `int`: an index from 0..size()-1 <br /> |

| Returns ||
|---|---|
| `int` | the character at the given index, or -1. <br /> |

### clear

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet clear ()
```

Removes all of the elements from this set. This set will be empty after this call returns.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### clone

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Object clone ()
```

Return a new set that is equivalent to this one.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Object` | a clone of this instance. <br /> |

### cloneAsThawed

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet cloneAsThawed ()
```

Clone a thawed version of this class, according to the Freezable interface.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | the clone, not frozen <br /> |

### closeOver

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet closeOver (int attribute)
```

Close this set over the given attribute. For the attribute `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE`, the result is to modify this set so that:

1. For each character or string 'a' in this set, all strings 'b' such that foldCase(a) == foldCase(b) are added to this set. (For most 'a' that are single characters, 'b' will have b.length() == 1.)
2. For each string 'e' in the resulting set, if e != foldCase(e), 'e' will be removed.

Example: \[aqß{Bc}{bC}{Fi}\] =\> \[aAqQß\\ufb01{ss}{bc}{fi}\]

(Here foldCase(x) refers to the operation UCharacter.foldCase(x, true), and a == b actually denotes a.equals(b), not pointer comparison.)

<br />

| Parameters ||
|---|---|
| `attribute` | `int`: bitmask for attributes to close over. Valid options: At most one of `https://developer.android.com/reference/android/icu/text/UnicodeSet#CASE_INSENSITIVE`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#ADD_CASE_MAPPINGS`, `https://developer.android.com/reference/android/icu/text/UnicodeSet#SIMPLE_CASE_INSENSITIVE`. These case options are mutually exclusive. Unrelated options bits are ignored. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | a reference to this set. <br /> |

### codePointStream

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public IntStream codePointStream ()
```

Returns an `https://developer.android.com/reference/java/util/stream/IntStream` of Unicode code point values from this `UnicodeSet`.

**Warnings:**

- To iterate over the full contents, you have to also iterate over the strings.
- For speed, `UnicodeSet` iteration does not check for concurrent modification.  
  Do not alter the `UnicodeSet` while iterating.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/stream/IntStream` | an `https://developer.android.com/reference/java/util/stream/IntStream` of Unicode code point values <br /> |

### codePoints

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Iterable<Integer> codePoints ()
```

Returns an `https://developer.android.com/reference/java/lang/Iterable` for iteration over all the code points in this set.

**Warnings:**

- This is a convenience method, but comes with a performance penalty because it boxes `int` into `Integer`.  
  For an efficient but old alternative use `https://developer.android.com/reference/android/icu/text/UnicodeSetIterator#next()`.
- To iterate over the full contents, you have to also iterate over the strings.
- For speed, `UnicodeSet` iteration does not check for concurrent modification.  
  Do not alter the `UnicodeSet` while iterating.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Iterable<https://developer.android.com/reference/java/lang/Integer>` | an `https://developer.android.com/reference/java/lang/Iterable` over all the code points <br /> |

### compact

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet compact ()
```

Reallocate this objects internal structures to take up the least possible space, without changing this object's value.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### compareTo

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int compareTo (UnicodeSet o)
```

Compares UnicodeSets, where shorter come first, and otherwise lexicographically (according to the comparison of the first characters that differ).

<br />

| Parameters ||
|---|---|
| `o` | `UnicodeSet` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Comparable#compareTo(T)`

### compareTo

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int compareTo (UnicodeSet o, 
                UnicodeSet.ComparisonStyle style)
```

Compares UnicodeSets, in three different ways.

<br />

| Parameters ||
|---|---|
| `o` | `UnicodeSet` <br /> |
| `style` | `UnicodeSet.ComparisonStyle` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Comparable#compareTo(T)`

### compareTo

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int compareTo (Iterable<String> other)
```

<br />

<br />

| Parameters ||
|---|---|
| `other` | `Iterable` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### complement

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet complement (int start, 
                int end)
```

Complements the specified range in this set. Any character in the range will be removed if it is in this set, or will be added if it is not in this set. If `start > end` then an empty range is complemented, leaving the set unchanged.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character, inclusive, of range <br /> |
| `end` | `int`: last character, inclusive, of range <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### complement

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet complement ()
```

This is equivalent to `complement(MIN_VALUE, MAX_VALUE)`.

**Note:** This performs a symmetric difference with all code points *and thus retains all multicharacter strings* . In order to achieve a \\u201ccode point complement\\u201d (all code points minus this set), the easiest is to .`https://developer.android.com/reference/android/icu/text/UnicodeSet#complement()`.`https://developer.android.com/reference/android/icu/text/UnicodeSet#removeAllStrings()` .

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### complement

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet complement (CharSequence s)
```

Complement the specified string in this set. The set will not contain the specified string once the call returns.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the string to complement <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### complement

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet complement (int c)
```

Complements the specified character in this set. The character will be removed if it is in this set, or will be added if it is not in this set.

<br />

| Parameters ||
|---|---|
| `c` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### complementAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet complementAll (CharSequence s)
```

Complement EACH of the characters in this string. Note: "ch" == {"c", "h"} If this set already any particular character, it has no effect on that character.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the source string <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### complementAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet complementAll (UnicodeSet c)
```

Complements in this set all elements contained in the specified set. Any character in the other set will be removed if it is in this set, or will be added if it is not in this set.

<br />

| Parameters ||
|---|---|
| `c` | `UnicodeSet`: set that defines which elements will be complemented from this set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### contains

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean contains (int c)
```

Returns true if this set contains the given character.

<br />

| Parameters ||
|---|---|
| `c` | `int`: character to be checked for containment <br /> |

| Returns ||
|---|---|
| `boolean` | true if the test condition is met <br /> |

### contains

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean contains (int start, 
                int end)
```

Returns true if this set contains every character of the given range.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character, inclusive, of the range <br /> |
| `end` | `int`: last character, inclusive, of the range <br /> |

| Returns ||
|---|---|
| `boolean` | true if the test condition is met <br /> |

### contains

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean contains (CharSequence s)
```

Returns `true` if this set contains the given multicharacter string.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: string to be checked for containment <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this set contains the specified string <br /> |

### containsAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsAll (UnicodeSet b)
```

Returns true if this set contains all the characters and strings of the given set.

<br />

| Parameters ||
|---|---|
| `b` | `UnicodeSet`: set to be checked for containment <br /> |

| Returns ||
|---|---|
| `boolean` | true if the test condition is met <br /> |

### containsAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsAll (Iterable<T> collection)
```

<br />

<br />

| Parameters ||
|---|---|
| `collection` | `Iterable` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#containsAll(android.icu.text.UnicodeSet)`

### containsAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsAll (String s)
```

Returns true if there is a partition of the string such that this set contains each of the partitioned strings. For example, for the Unicode set \[a{bc}{cd}\]  

containsAll is true for each of: "a", "bc", ""cdbca"  

containsAll is false for each of: "acb", "bcda", "bcx"  

<br />

| Parameters ||
|---|---|
| `s` | `String`: string containing characters to be checked for containment <br /> |

| Returns ||
|---|---|
| `boolean` | true if the test condition is met <br /> |

### containsNone

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsNone (Iterable<T> collection)
```

<br />

<br />

| Parameters ||
|---|---|
| `collection` | `Iterable` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#containsNone(android.icu.text.UnicodeSet)`

### containsNone

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsNone (UnicodeSet b)
```

Returns true if none of the characters or strings in this UnicodeSet appears in the string. For example, for the Unicode set \[a{bc}{cd}\]  

containsNone is true for: "xy", "cb"  

containsNone is false for: "a", "bc", "bcd"  

<br />

| Parameters ||
|---|---|
| `b` | `UnicodeSet`: set to be checked for containment <br /> |

| Returns ||
|---|---|
| `boolean` | true if the test condition is met <br /> |

### containsNone

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsNone (CharSequence s)
```

Returns true if this set contains none of the characters of the given string.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: string containing characters to be checked for containment <br /> |

| Returns ||
|---|---|
| `boolean` | true if the test condition is met <br /> |

### containsNone

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean containsNone (int start, 
                int end)
```

Returns true if this set contains none of the characters of the given range.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character, inclusive, of the range <br /> |
| `end` | `int`: last character, inclusive, of the range <br /> |

| Returns ||
|---|---|
| `boolean` | true if the test condition is met <br /> |

### containsSome

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean containsSome (UnicodeSet s)
```

Returns true if this set contains one or more of the characters and strings of the given set.

<br />

| Parameters ||
|---|---|
| `s` | `UnicodeSet`: set to be checked for containment <br /> |

| Returns ||
|---|---|
| `boolean` | true if the condition is met <br /> |

### containsSome

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean containsSome (CharSequence s)
```

Returns true if this set contains one or more of the characters of the given string.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: string containing characters to be checked for containment <br /> |

| Returns ||
|---|---|
| `boolean` | true if the condition is met <br /> |

### containsSome

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean containsSome (Iterable<T> collection)
```

<br />

<br />

| Parameters ||
|---|---|
| `collection` | `Iterable` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#containsAll(android.icu.text.UnicodeSet)`

### containsSome

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final boolean containsSome (int start, 
                int end)
```

Returns true if this set contains one or more of the characters in the given range.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character, inclusive, of the range <br /> |
| `end` | `int`: last character, inclusive, of the range <br /> |

| Returns ||
|---|---|
| `boolean` | true if the condition is met <br /> |

### equals

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object o)
```

Compares the specified object with this set for equality. Returns `true` if the specified object is also a set, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set).

<br />

| Parameters ||
|---|---|
| `o` | `Object`: Object to be compared for equality with this set. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if the specified Object is equal to this set. <br /> |

### freeze

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet freeze ()
```

Freeze this class, according to the Freezable interface.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this <br /> |

### from

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static UnicodeSet from (CharSequence s)
```

Makes a set from a multicharacter string. Thus "ch" =\> {"ch"}

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the source string <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | a newly created set containing the given string <br /> |

### fromAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static UnicodeSet fromAll (CharSequence s)
```

Makes a set from each of the characters in the string. Thus "ch" =\> {"c", "h"}

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the source string <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | a newly created set containing the given characters <br /> |

### getRangeCount

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getRangeCount ()
```

Iteration method that returns the number of ranges contained in this set.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeStart(int)`
- `https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeEnd(int)`

### getRangeEnd

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getRangeEnd (int index)
```

Iteration method that returns the last character in the specified range of this set.

<br />

| Parameters ||
|---|---|
| `index` | `int` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` | if index is outside the range `0..getRangeCount()-1` |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeStart(int)`
- `https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeEnd(int)`

### getRangeStart

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getRangeStart (int index)
```

Iteration method that returns the first character in the specified range of this set.

<br />

| Parameters ||
|---|---|
| `index` | `int` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException` | if index is outside the range `0..getRangeCount()-1` |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeCount()`
- `https://developer.android.com/reference/android/icu/text/UnicodeSet#getRangeEnd(int)`

### hasStrings

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasStrings ()
```

<br />

<br />

| Returns ||
|---|---|
| `boolean` | true if this set contains multi-character strings or the empty string. <br /> |

### hashCode

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns the hash code value for this set.

<br />

| Returns ||
|---|---|
| `int` | the hash code value for this set. <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Object#hashCode()`

### indexOf

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int indexOf (int c)
```

Returns the index of the given character within this set, where the set is ordered by ascending code point. If the character is not in this set, return -1. The inverse of this method is `charAt()`.

<br />

| Parameters ||
|---|---|
| `c` | `int` <br /> |

| Returns ||
|---|---|
| `int` | an index from 0..size()-1, or -1 <br /> |

### isEmpty

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isEmpty ()
```

Returns `true` if this set contains no elements.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if this set contains no elements. <br /> |

### isFrozen

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isFrozen ()
```

Is this frozen, according to the Freezable interface?

<br />

| Returns ||
|---|---|
| `boolean` | value <br /> |

### iterator

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Iterator<String> iterator ()
```

Returns a string iterator. Uses the same order of iteration as `https://developer.android.com/reference/android/icu/text/UnicodeSetIterator`.

**Warning:**For speed, UnicodeSet iteration does not check for concurrent modification. Do not alter the UnicodeSet while iterating.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Iterator<https://developer.android.com/reference/java/lang/String>` | an Iterator. <br /> |

**See also:**

- `https://developer.android.com/reference/java/util/Set#iterator()`

### matches

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int matches (Replaceable text, 
                int[] offset, 
                int limit, 
                boolean incremental)
```

Implementation of UnicodeMatcher.matches(). Always matches the longest possible multichar string.

<br />

| Parameters ||
|---|---|
| `text` | `Replaceable`: the text to be matched <br /> |
| `offset` | `int`: on input, the index into text at which to begin matching. On output, the limit of the matched text. The number of matched characters is the output value of offset minus the input value. Offset should always point to the HIGH SURROGATE (leading code unit) of a pair of surrogates, both on entry and upon return. <br /> |
| `limit` | `int`: the limit index of text to be matched. Greater than offset for a forward direction match, less than offset for a backward direction match. The last character to be considered for matching will be text.charAt(limit-1) in the forward direction or text.charAt(limit+1) in the backward direction. <br /> |
| `incremental` | `boolean`: if true, then assume further characters may be inserted at limit and check for partial matching. Otherwise assume the text as given is complete. <br /> |

| Returns ||
|---|---|
| `int` | a match degree value indicating a full match, a partial match, or a mismatch. If incremental is false then U_PARTIAL_MATCH should never be returned. <br /> |

### matchesIndexValue

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean matchesIndexValue (int v)
```

Implementation of UnicodeMatcher API. Returns `true` if this set contains any character whose low byte is the given value. This is used by `RuleBasedTransliterator` for indexing.

<br />

| Parameters ||
|---|---|
| `v` | `int` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### rangeStream

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Stream<UnicodeSet.EntryRange> rangeStream ()
```

Returns a `https://developer.android.com/reference/java/util/stream/Stream` of `https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange` values from this `UnicodeSet`.

**Warnings:**

- The `https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange` instance is the same each time; the contents are just reset.
- To iterate over the full contents, you have to also iterate over the strings.
- For speed, `UnicodeSet` iteration does not check for concurrent modification.  
  Do not alter the `UnicodeSet` while iterating.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/stream/Stream<https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange>` | a `https://developer.android.com/reference/java/util/stream/Stream` of `https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange` <br /> |

### ranges

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Iterable<UnicodeSet.EntryRange> ranges ()
```

Provide for faster iteration than by String. Returns an Iterable/Iterator over ranges of code points. The UnicodeSet must not be altered during the iteration. The EntryRange instance is the same each time; the contents are just reset.

**Warning:**To iterate over the full contents, you have to also iterate over the strings.

**Warning:**For speed, UnicodeSet iteration does not check for concurrent modification. Do not alter the UnicodeSet while iterating.

```
// Sample code
for (EntryRange range : us1.ranges()) {
    // do something with code points between range.codepoint and range.codepointEnd;
}
for (String s : us1.strings()) {
    // do something with each string;
}
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Iterable<https://developer.android.com/reference/android/icu/text/UnicodeSet.EntryRange>` | <br /> |

### remove

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet remove (int start, 
                int end)
```

Removes the specified range from this set if it is present. The set will not contain the specified range once the call returns. If `start > end` then an empty range is removed, leaving the set unchanged.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character, inclusive, of range to be removed from this set. <br /> |
| `end` | `int`: last character, inclusive, of range to be removed from this set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### remove

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet remove (CharSequence s)
```

Removes the specified string from this set if it is present. The set will not contain the specified string once the call returns.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the string to be removed <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### remove

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet remove (int c)
```

Removes the specified character from this set if it is present. The set will not contain the specified character once the call returns.

<br />

| Parameters ||
|---|---|
| `c` | `int`: the character to be removed <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### removeAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet removeAll (Iterable<T> collection)
```

<br />

<br />

| Parameters ||
|---|---|
| `collection` | `Iterable` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#removeAll(android.icu.text.UnicodeSet)`

### removeAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet removeAll (UnicodeSet c)
```

Removes from this set all of its elements that are contained in the specified set. This operation effectively modifies this set so that its value is the *asymmetric set difference* of the two sets.

<br />

| Parameters ||
|---|---|
| `c` | `UnicodeSet`: set that defines which elements will be removed from this set. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### removeAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet removeAll (CharSequence s)
```

Remove EACH of the characters in this string. Note: "ch" == {"c", "h"} If this set already any particular character, it has no effect on that character.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the source string <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### removeAllStrings

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet removeAllStrings ()
```

Remove all strings from this UnicodeSet

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### retain

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet retain (int start, 
                int end)
```

Retain only the elements in this set that are contained in the specified range. If `start > end` then an empty range is retained, leaving the set empty.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character, inclusive, of range <br /> |
| `end` | `int`: last character, inclusive, of range <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### retain

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet retain (CharSequence cs)
```

Retain the specified string in this set if it is present. Upon return this set will be empty if it did not contain s, or will only contain s if it did contain s.

<br />

| Parameters ||
|---|---|
| `cs` | `CharSequence`: the string to be retained <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### retain

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet retain (int c)
```

Retain the specified character from this set if it is present. Upon return this set will be empty if it did not contain c, or will only contain c if it did contain c.

<br />

| Parameters ||
|---|---|
| `c` | `int`: the character to be retained <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### retainAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final UnicodeSet retainAll (CharSequence s)
```

Retains EACH of the characters in this string. Note: "ch" == {"c", "h"} If this set already any particular character, it has no effect on that character.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: the source string <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | this object, for chaining <br /> |

### retainAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet retainAll (UnicodeSet c)
```

Retains only the elements in this set that are contained in the specified set. In other words, removes from this set all of its elements that are not contained in the specified set. This operation effectively modifies this set so that its value is the *intersection* of the two sets.

<br />

| Parameters ||
|---|---|
| `c` | `UnicodeSet`: set that defines which elements this set will retain. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### retainAll

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet retainAll (Iterable<T> collection)
```

<br />

<br />

| Parameters ||
|---|---|
| `collection` | `Iterable` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/icu/text/UnicodeSet#retainAll(android.icu.text.UnicodeSet)`

### set

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet set (UnicodeSet other)
```

Make this object represent the same set as `other`.

<br />

| Parameters ||
|---|---|
| `other` | `UnicodeSet`: a `UnicodeSet` whose value will be copied to this object <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### set

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UnicodeSet set (int start, 
                int end)
```

Make this object represent the range `start - end`. If `start > end` then this object is set to an empty range.

<br />

| Parameters ||
|---|---|
| `start` | `int`: first character in the set, inclusive <br /> |
| `end` | `int`: last character in the set, inclusive <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/UnicodeSet` | <br /> |

### size

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int size ()
```

Returns the number of elements in this set (its cardinality) Note than the elements of a set may include both individual codepoints and strings.

<br />

| Returns ||
|---|---|
| `int` | the number of elements in this set (its cardinality). <br /> |

### span

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int span (CharSequence s, 
                int start, 
                UnicodeSet.SpanCondition spanCondition)
```

Span a string using this UnicodeSet. If the start index is less than 0, span will start from 0. If the start index is greater than the string length, span returns the string length.

To replace, count elements, or delete spans, see `https://developer.android.com/reference/android/icu/text/UnicodeSetSpanner`.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: The string to be spanned <br /> |
| `start` | `int`: The start index that the span begins <br /> |
| `spanCondition` | `UnicodeSet.SpanCondition`: The span condition <br /> |

| Returns ||
|---|---|
| `int` | the string index which ends the span (i.e. exclusive) <br /> |

### span

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int span (CharSequence s, 
                UnicodeSet.SpanCondition spanCondition)
```

Span a string using this UnicodeSet.

To replace, count elements, or delete spans, see `https://developer.android.com/reference/android/icu/text/UnicodeSetSpanner`.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: The string to be spanned <br /> |
| `spanCondition` | `UnicodeSet.SpanCondition`: The span condition <br /> |

| Returns ||
|---|---|
| `int` | the length of the span <br /> |

### spanBack

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int spanBack (CharSequence s, 
                UnicodeSet.SpanCondition spanCondition)
```

Span a string backwards (from the end) using this UnicodeSet.

To replace, count elements, or delete spans, see `https://developer.android.com/reference/android/icu/text/UnicodeSetSpanner`.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: The string to be spanned <br /> |
| `spanCondition` | `UnicodeSet.SpanCondition`: The span condition <br /> |

| Returns ||
|---|---|
| `int` | The string index which starts the span (i.e. inclusive). <br /> |

### spanBack

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int spanBack (CharSequence s, 
                int fromIndex, 
                UnicodeSet.SpanCondition spanCondition)
```

Span a string backwards (from the fromIndex) using this UnicodeSet. If the fromIndex is less than 0, spanBack will return 0. If fromIndex is greater than the string length, spanBack will start from the string length.

To replace, count elements, or delete spans, see `https://developer.android.com/reference/android/icu/text/UnicodeSetSpanner`.

<br />

| Parameters ||
|---|---|
| `s` | `CharSequence`: The string to be spanned <br /> |
| `fromIndex` | `int`: The index of the char (exclusive) that the string should be spanned backwards <br /> |
| `spanCondition` | `UnicodeSet.SpanCondition`: The span condition <br /> |

| Returns ||
|---|---|
| `int` | The string index which starts the span (i.e. inclusive). <br /> |

### stream

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Stream<String> stream ()
```

Returns a stream of `String` values from this `UnicodeSet`.

**Warnings:**

- To iterate over the full contents, you have to also iterate over the strings.
- For speed, `UnicodeSet` iteration does not check for concurrent modification.  
  Do not alter the `UnicodeSet` while iterating.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/stream/Stream<https://developer.android.com/reference/java/lang/String>` | a `https://developer.android.com/reference/java/util/stream/Stream` of `String` <br /> |

### stringStream

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Stream<String> stringStream ()
```

Returns a `https://developer.android.com/reference/java/util/stream/Stream` of `String` values from this `UnicodeSet`.

**Warnings:**

- To iterate over the full contents, you have to also iterate over the ranges or code points.
- For speed, `UnicodeSet` iteration does not check for concurrent modification.  
  Do not alter the `UnicodeSet` while iterating.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/stream/Stream<https://developer.android.com/reference/java/lang/String>` | a `https://developer.android.com/reference/java/util/stream/Stream` of `String` <br /> |

### strings

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Collection<String> strings ()
```

For iterating through the strings in the set. Example:

```
for (String key : myUnicodeSet.strings()) {
  doSomethingWith(key);
}
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Collection<https://developer.android.com/reference/java/lang/String>` | <br /> |

### toPattern

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toPattern (boolean escapeUnprintable)
```

Returns a string representation of this set. If the result of calling this function is passed to a UnicodeSet constructor, it will produce another set that is equal to this one.

<br />

| Parameters ||
|---|---|
| `escapeUnprintable` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### toString

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Return a programmer-readable string representation of this object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |