Patterns
  public
  
  
  
  class
  Patterns
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.util.Patterns | 
Commonly used regular expression patterns.
Summary
| Constants | |
|---|---|
| String | GOOD_IRI_CHARThis constant was deprecated in API level 24. Deprecated since it does not include all IRI characters defined in RFC 3987 | 
| String | TOP_LEVEL_DOMAIN_STRThis constant was deprecated in API level 21. Due to the recent profileration of gTLDs, this API is expected to become out-of-date very quickly. Therefore it is now deprecated. | 
| String | TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL
      This constant was deprecated
      in API level 21.
    This API is deprecated. See  | 
| Fields | |
|---|---|
| 
    public
    static
    final
    Pattern | DOMAIN_NAME
 | 
| 
    public
    static
    final
    Pattern | EMAIL_ADDRESS
 | 
| 
    public
    static
    final
    Pattern | IP_ADDRESS
      This field was deprecated
      in API level 31.
    Please use  | 
| 
    public
    static
    final
    Pattern | PHONEThis 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. | 
| 
    public
    static
    final
    Pattern | TOP_LEVEL_DOMAIN
      This field was deprecated
      in API level 21.
    This API is deprecated. See  | 
| 
    public
    static
    final
    Pattern | WEB_URLRegular expression pattern to match most part of RFC 3987 Internationalized URLs, aka IRIs. | 
| Public methods | |
|---|---|
| 
        
        
        static
        final
        
        String | 
      concatGroups(Matcher matcher)
      Convenience method to take all of the non-null matching groups in a regex Matcher and return them as a concatenated string. | 
| 
        
        
        static
        final
        
        String | 
      digitsAndPlusOnly(Matcher matcher)
      Convenience method to return only the digits and plus signs in the matching string. | 
| Inherited methods | |
|---|---|
Constants
GOOD_IRI_CHAR
public static final String GOOD_IRI_CHAR
      This constant was deprecated
      in API level 24.
    Deprecated since it does not include all IRI characters defined in RFC 3987
  
Kept for backward compatibility reasons.
Constant Value: "a-zA-Z0-9 -豈-﷏ﷰ-"
TOP_LEVEL_DOMAIN_STR
public static final String TOP_LEVEL_DOMAIN_STR
      This constant was deprecated
      in API level 21.
    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
Constant 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]|(δοκιμή|испытание|рф|срб|טעסט|آزمایشی|إختبار|الاردن|الجزائر|السعودية|المغرب|امارات|بھارت|تونس|سورية|فلسطين|قطر|مصر|परीक्षा|भारत|ভারত|ਭਾਰਤ|ભારત|இந்தியா|இலங்கை|சிங்கப்பூர்|பரிட்சை|భారత్|ලංකා|ไทย|テスト|中国|中國|台湾|台灣|新加坡|测试|測試|香港|테스트|한국|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
public static final String TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL
      This constant was deprecated
      in API level 21.
    This API is deprecated. See TOP_LEVEL_DOMAIN_STR.
  
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
Constant 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]|(?:δοκιμή|испытание|рф|срб|טעסט|آزمایشی|إختبار|الاردن|الجزائر|السعودية|المغرب|امارات|بھارت|تونس|سورية|فلسطين|قطر|مصر|परीक्षा|भारत|ভারত|ਭਾਰਤ|ભારત|இந்தியா|இலங்கை|சிங்கப்பூர்|பரிட்சை|భారత్|ලංකා|ไทย|テスト|中国|中國|台湾|台灣|新加坡|测试|測試|香港|테스트|한국|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]))"
Fields
IP_ADDRESS
public static final Pattern IP_ADDRESS
      This field was deprecated
      in API level 31.
    Please use InetAddresses.isNumericAddress(String) instead.
  
Kept for backward compatibility reasons. It does not match IPv6 addresses.
PHONE
public static final Pattern PHONE
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
public static final Pattern TOP_LEVEL_DOMAIN
      This field was deprecated
      in API level 21.
    This API is deprecated. See TOP_LEVEL_DOMAIN_STR.
  
Regular expression pattern to match all IANA top-level domains.
WEB_URL
public static final Pattern WEB_URL
Regular expression pattern to match most part of RFC 3987 Internationalized URLs, aka IRIs.
Public methods
concatGroups
public static final String concatGroups (Matcher matcher)
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: The Matcher object from which grouped text will
                      be extracted | 
| Returns | |
|---|---|
| String | A String comprising all of the non-null matched groups concatenated together | 
digitsAndPlusOnly
public static final String digitsAndPlusOnly (Matcher matcher)
Convenience method to return only the digits and plus signs in the matching string.
| Parameters | |
|---|---|
| matcher | Matcher: The Matcher object from which digits and plus will
                     be extracted | 
| Returns | |
|---|---|
| String | A String comprising all of the digits and plus in the match | 
