# Patterns

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

# Patterns

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/util/Patterns "View this page in Java")  

```
open class Patterns
```

|---|------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                 ||
| ↳ | [android.util.Patterns](https://developer.android.com/reference/kotlin/android/util/Patterns#) |

Commonly used regular expression patterns.

## Summary

|                                                                                                                                                      Constants                                                                                                                                                      ||
|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [GOOD_IRI_CHAR](https://developer.android.com/reference/kotlin/android/util/Patterns#GOOD_IRI_CHAR:kotlin.String) Kept for backward compatibility reasons.                                                                  |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [TOP_LEVEL_DOMAIN_STR](https://developer.android.com/reference/kotlin/android/util/Patterns#TOP_LEVEL_DOMAIN_STR:kotlin.String) Regular expression to match all IANA top-level domains.                                     |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL](https://developer.android.com/reference/kotlin/android/util/Patterns#TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL:kotlin.String) Regular expression to match all IANA top-level domains for WEB_URL. |

|                                                                                                                                                                                                                      Public methods                                                                                                                                                                                                                      ||
|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [concatGroups](https://developer.android.com/reference/kotlin/android/util/Patterns#concatGroups(java.util.regex.Matcher))`(`matcher:` `[Matcher](https://developer.android.com/reference/kotlin/java/util/regex/Matcher.html#)!`)` Convenience method to take all of the non-null matching groups in a regex Matcher and return them as a concatenated string. |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [digitsAndPlusOnly](https://developer.android.com/reference/kotlin/android/util/Patterns#digitsAndPlusOnly(java.util.regex.Matcher))`(`matcher:` `[Matcher](https://developer.android.com/reference/kotlin/java/util/regex/Matcher.html#)!`)` Convenience method to return only the digits and plus signs in the matching string.                               |

|                                                                                                                                                                                         Properties                                                                                                                                                                                          ||
|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)! | [DOMAIN_NAME](https://developer.android.com/reference/kotlin/android/util/Patterns#DOMAIN_NAME:java.util.regex.Pattern) <br />                                                                                                                                                              |
| static[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)! | [EMAIL_ADDRESS](https://developer.android.com/reference/kotlin/android/util/Patterns#EMAIL_ADDRESS:java.util.regex.Pattern) <br />                                                                                                                                                          |
| static[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)! | [IP_ADDRESS](https://developer.android.com/reference/kotlin/android/util/Patterns#IP_ADDRESS:java.util.regex.Pattern) Kept for backward compatibility reasons.                                                                                                                              |
| static[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)! | [PHONE](https://developer.android.com/reference/kotlin/android/util/Patterns#PHONE:java.util.regex.Pattern) This pattern is intended for searching for things that look like they might be phone numbers in arbitrary text, not for validating whether something is in fact a phone number. |
| static[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)! | [TOP_LEVEL_DOMAIN](https://developer.android.com/reference/kotlin/android/util/Patterns#TOP_LEVEL_DOMAIN:java.util.regex.Pattern) Regular expression pattern to match all IANA top-level domains.                                                                                           |
| static[Pattern](https://developer.android.com/reference/kotlin/java/util/regex/Pattern.html#)! | [WEB_URL](https://developer.android.com/reference/kotlin/android/util/Patterns#WEB_URL:java.util.regex.Pattern) Regular expression pattern to match most part of RFC 3987 Internationalized URLs, aka IRIs.                                                                                 |

## Constants

### GOOD_IRI_CHAR

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

```
static val GOOD_IRI_CHAR: String
```

**Deprecated:** *Deprecated since it does not include all IRI characters defined in RFC 3987*

Kept for backward compatibility reasons.  

    Value: "a-zA-Z0-9\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef"

### TOP_LEVEL_DOMAIN_STR

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

```
static val TOP_LEVEL_DOMAIN_STR: String
```

**Deprecated:** *Due to the recent profileration of gTLDs, this API is expected to become out-of-date very quickly. Therefore it is now deprecated.*

Regular expression to match all IANA top-level domains. List accurate as of 2011/07/18. List taken from: http://data.iana.org/TLD/tlds-alpha-by-domain.txt This pattern is auto-generated by frameworks/ex/common/tools/make-iana-tld-pattern.py  

    Value: "((aero|arpa|asia|a[cdefgilmnoqrstuwxz])|(biz|b[abdefghijmnorstvwyz])|(cat|com|coop|c[acdfghiklmnoruvxyz])|d[ejkmoz]|(edu|e[cegrstu])|f[ijkmor]|(gov|g[abdefghilmnpqrstuwy])|h[kmnrtu]|(info|int|i[delmnoqrst])|(jobs|j[emop])|k[eghimnprwyz]|l[abcikrstuvy]|(mil|mobi|museum|m[acdeghklmnopqrstuvwxyz])|(name|net|n[acefgilopruz])|(org|om)|(pro|p[aefghklmnrstwy])|qa|r[eosuw]|s[abcdeghijklmnortuvyz]|(tel|travel|t[cdfghjklmnoprtvwz])|u[agksyz]|v[aceginu]|w[fs]|(\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae|\u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0435|\u0440\u0444|\u0441\u0440\u0431|\u05d8\u05e2\u05e1\u05d8|\u0622\u0632\u0645\u0627\u06cc\u0634\u06cc|\u0625\u062e\u062a\u0628\u0627\u0631|\u0627\u0644\u0627\u0631\u062f\u0646|\u0627\u0644\u062c\u0632\u0627\u0626\u0631|\u0627\u0644\u0633\u0639\u0648\u062f\u064a\u0629|\u0627\u0644\u0645\u063a\u0631\u0628|\u0627\u0645\u0627\u0631\u0627\u062a|\u0628\u06be\u0627\u0631\u062a|\u062a\u0648\u0646\u0633|\u0633\u0648\u0631\u064a\u0629|\u0641\u0644\u0633\u0637\u064a\u0646|\u0642\u0637\u0631|\u0645\u0635\u0631|\u092a\u0930\u0940\u0915\u094d\u0937\u093e|\u092d\u093e\u0930\u0924|\u09ad\u09be\u09b0\u09a4|\u0a2d\u0a3e\u0a30\u0a24|\u0aad\u0abe\u0ab0\u0aa4|\u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe|\u0b87\u0bb2\u0b99\u0bcd\u0b95\u0bc8|\u0b9a\u0bbf\u0b99\u0bcd\u0b95\u0baa\u0bcd\u0baa\u0bc2\u0bb0\u0bcd|\u0baa\u0bb0\u0bbf\u0b9f\u0bcd\u0b9a\u0bc8|\u0c2d\u0c3e\u0c30\u0c24\u0c4d|\u0dbd\u0d82\u0d9a\u0dcf|\u0e44\u0e17\u0e22|\u30c6\u30b9\u30c8|\u4e2d\u56fd|\u4e2d\u570b|\u53f0\u6e7e|\u53f0\u7063|\u65b0\u52a0\u5761|\u6d4b\u8bd5|\u6e2c\u8a66|\u9999\u6e2f|\ud14c\uc2a4\ud2b8|\ud55c\uad6d|xn\\-\\-0zwm56d|xn\\-\\-11b5bs3a9aj6g|xn\\-\\-3e0b707e|xn\\-\\-45brj9c|xn\\-\\-80akhbyknj4f|xn\\-\\-90a3ac|xn\\-\\-9t4b11yi5a|xn\\-\\-clchc0ea0b2g2a9gcd|xn\\-\\-deba0ad|xn\\-\\-fiqs8s|xn\\-\\-fiqz9s|xn\\-\\-fpcrj9c3d|xn\\-\\-fzc2c9e2c|xn\\-\\-g6w251d|xn\\-\\-gecrj9c|xn\\-\\-h2brj9c|xn\\-\\-hgbk6aj7f53bba|xn\\-\\-hlcj6aya9esc7a|xn\\-\\-j6w193g|xn\\-\\-jxalpdlp|xn\\-\\-kgbechtv|xn\\-\\-kprw13d|xn\\-\\-kpry57d|xn\\-\\-lgbbat1ad8j|xn\\-\\-mgbaam7a8h|xn\\-\\-mgbayh7gpa|xn\\-\\-mgbbh1a71e|xn\\-\\-mgbc0a9azcg|xn\\-\\-mgberp4a5d4ar|xn\\-\\-o3cw4h|xn\\-\\-ogbpf8fl|xn\\-\\-p1ai|xn\\-\\-pgbs0dh|xn\\-\\-s9brj9c|xn\\-\\-wgbh1c|xn\\-\\-wgbl6a|xn\\-\\-xkc2al3hye2a|xn\\-\\-xkc2dl3a5ee0h|xn\\-\\-yfro4i67o|xn\\-\\-ygbi2ammx|xn\\-\\-zckzah|xxx)|y[et]|z[amw])"

### TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL

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

```
static val TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL: String
```

**Deprecated:** *This API is deprecated. See[TOP_LEVEL_DOMAIN_STR](https://developer.android.com/reference/kotlin/android/util/Patterns#TOP_LEVEL_DOMAIN_STR:kotlin.String).*

Regular expression to match all IANA top-level domains for WEB_URL. List accurate as of 2011/07/18. List taken from: http://data.iana.org/TLD/tlds-alpha-by-domain.txt This pattern is auto-generated by frameworks/ex/common/tools/make-iana-tld-pattern.py  

    Value: "(?:(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])|(?:biz|b[abdefghijmnorstvwyz])|(?:cat|com|coop|c[acdfghiklmnoruvxyz])|d[ejkmoz]|(?:edu|e[cegrstu])|f[ijkmor]|(?:gov|g[abdefghilmnpqrstuwy])|h[kmnrtu]|(?:info|int|i[delmnoqrst])|(?:jobs|j[emop])|k[eghimnprwyz]|l[abcikrstuvy]|(?:mil|mobi|museum|m[acdeghklmnopqrstuvwxyz])|(?:name|net|n[acefgilopruz])|(?:org|om)|(?:pro|p[aefghklmnrstwy])|qa|r[eosuw]|s[abcdeghijklmnortuvyz]|(?:tel|travel|t[cdfghjklmnoprtvwz])|u[agksyz]|v[aceginu]|w[fs]|(?:\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae|\u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0435|\u0440\u0444|\u0441\u0440\u0431|\u05d8\u05e2\u05e1\u05d8|\u0622\u0632\u0645\u0627\u06cc\u0634\u06cc|\u0625\u062e\u062a\u0628\u0627\u0631|\u0627\u0644\u0627\u0631\u062f\u0646|\u0627\u0644\u062c\u0632\u0627\u0626\u0631|\u0627\u0644\u0633\u0639\u0648\u062f\u064a\u0629|\u0627\u0644\u0645\u063a\u0631\u0628|\u0627\u0645\u0627\u0631\u0627\u062a|\u0628\u06be\u0627\u0631\u062a|\u062a\u0648\u0646\u0633|\u0633\u0648\u0631\u064a\u0629|\u0641\u0644\u0633\u0637\u064a\u0646|\u0642\u0637\u0631|\u0645\u0635\u0631|\u092a\u0930\u0940\u0915\u094d\u0937\u093e|\u092d\u093e\u0930\u0924|\u09ad\u09be\u09b0\u09a4|\u0a2d\u0a3e\u0a30\u0a24|\u0aad\u0abe\u0ab0\u0aa4|\u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe|\u0b87\u0bb2\u0b99\u0bcd\u0b95\u0bc8|\u0b9a\u0bbf\u0b99\u0bcd\u0b95\u0baa\u0bcd\u0baa\u0bc2\u0bb0\u0bcd|\u0baa\u0bb0\u0bbf\u0b9f\u0bcd\u0b9a\u0bc8|\u0c2d\u0c3e\u0c30\u0c24\u0c4d|\u0dbd\u0d82\u0d9a\u0dcf|\u0e44\u0e17\u0e22|\u30c6\u30b9\u30c8|\u4e2d\u56fd|\u4e2d\u570b|\u53f0\u6e7e|\u53f0\u7063|\u65b0\u52a0\u5761|\u6d4b\u8bd5|\u6e2c\u8a66|\u9999\u6e2f|\ud14c\uc2a4\ud2b8|\ud55c\uad6d|xn\\-\\-0zwm56d|xn\\-\\-11b5bs3a9aj6g|xn\\-\\-3e0b707e|xn\\-\\-45brj9c|xn\\-\\-80akhbyknj4f|xn\\-\\-90a3ac|xn\\-\\-9t4b11yi5a|xn\\-\\-clchc0ea0b2g2a9gcd|xn\\-\\-deba0ad|xn\\-\\-fiqs8s|xn\\-\\-fiqz9s|xn\\-\\-fpcrj9c3d|xn\\-\\-fzc2c9e2c|xn\\-\\-g6w251d|xn\\-\\-gecrj9c|xn\\-\\-h2brj9c|xn\\-\\-hgbk6aj7f53bba|xn\\-\\-hlcj6aya9esc7a|xn\\-\\-j6w193g|xn\\-\\-jxalpdlp|xn\\-\\-kgbechtv|xn\\-\\-kprw13d|xn\\-\\-kpry57d|xn\\-\\-lgbbat1ad8j|xn\\-\\-mgbaam7a8h|xn\\-\\-mgbayh7gpa|xn\\-\\-mgbbh1a71e|xn\\-\\-mgbc0a9azcg|xn\\-\\-mgberp4a5d4ar|xn\\-\\-o3cw4h|xn\\-\\-ogbpf8fl|xn\\-\\-p1ai|xn\\-\\-pgbs0dh|xn\\-\\-s9brj9c|xn\\-\\-wgbh1c|xn\\-\\-wgbl6a|xn\\-\\-xkc2al3hye2a|xn\\-\\-xkc2dl3a5ee0h|xn\\-\\-yfro4i67o|xn\\-\\-ygbi2ammx|xn\\-\\-zckzah|xxx)|y[et]|z[amw]))"

## Public methods

### concatGroups

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

```
static fun concatGroups(matcher: Matcher!): String!
```

Convenience method to take all of the non-null matching groups in a regex Matcher and return them as a concatenated string.

|                                                                            Parameters                                                                            ||
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `matcher` | [Matcher](https://developer.android.com/reference/kotlin/java/util/regex/Matcher.html#)!:The Matcher object from which grouped text will be extracted |

|                                                                             Return                                                                              ||
|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | A String comprising all of the non-null matched groups concatenated together |

### digitsAndPlusOnly

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

```
static fun digitsAndPlusOnly(matcher: Matcher!): String!
```

Convenience method to return only the digits and plus signs in the matching string.

|                                                                             Parameters                                                                              ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `matcher` | [Matcher](https://developer.android.com/reference/kotlin/java/util/regex/Matcher.html#)!:The Matcher object from which digits and plus will be extracted |

|                                                                     Return                                                                     ||
|-----------------------------------------------------------------------------------|-------------------------------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | A String comprising all of the digits and plus in the match |

## Properties

### DOMAIN_NAME

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

```
static val DOMAIN_NAME: Pattern!
```  

### EMAIL_ADDRESS

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

```
static val EMAIL_ADDRESS: Pattern!
```  

### IP_ADDRESS

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

```
static val IP_ADDRESS: Pattern!
```

**Deprecated:** *Please use[android.net.InetAddresses#isNumericAddress(String)](https://developer.android.com/reference/kotlin/android/net/InetAddresses.html#isNumericAddress(kotlin.String))instead.*

Kept for backward compatibility reasons. It does not match IPv6 addresses.  

### PHONE

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

```
static val PHONE: Pattern!
```

This pattern is intended for searching for things that look like they might be phone numbers in arbitrary text, not for validating whether something is in fact a phone number. It will miss many things that are legitimate phone numbers.

The pattern matches the following:

- Optionally, a + sign followed immediately by one or more digits. Spaces, dots, or dashes may follow.
- Optionally, sets of digits in parentheses, separated by spaces, dots, or dashes.
- A string starting and ending with a digit, containing digits, spaces, dots, and/or dashes.  

### TOP_LEVEL_DOMAIN

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

```
static val TOP_LEVEL_DOMAIN: Pattern!
```

**Deprecated:** *This API is deprecated. See[TOP_LEVEL_DOMAIN_STR](https://developer.android.com/reference/kotlin/android/util/Patterns#TOP_LEVEL_DOMAIN_STR:kotlin.String).*

Regular expression pattern to match all IANA top-level domains.  

### WEB_URL

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

```
static val WEB_URL: Pattern!
```

Regular expression pattern to match most part of RFC 3987 Internationalized URLs, aka IRIs.