# PatternSyntaxException

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

# PatternSyntaxException

```
open class PatternSyntaxException : IllegalArgumentException
```

|---|---|---|---|---|----------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                               ||||||
| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)                                                |||||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#)                                           ||||
|   |   | ↳ | [java.lang.RuntimeException](https://developer.android.com/reference/kotlin/java/lang/RuntimeException.html#)                          |||
|   |   |   | ↳ | [java.lang.IllegalArgumentException](https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#)       ||
|   |   |   |   | ↳ | [java.util.regex.PatternSyntaxException](https://developer.android.com/reference/kotlin/java/util/regex/PatternSyntaxException#) |

Unchecked exception thrown to indicate a syntax error in a regular-expression pattern.

## Summary

|                                                                                                                                                                                                                                                 Public constructors                                                                                                                                                                                                                                                  ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [PatternSyntaxException](https://developer.android.com/reference/kotlin/java/util/regex/PatternSyntaxException#PatternSyntaxException(kotlin.String,%20kotlin.String,%20kotlin.Int))`(`desc:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `regex:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Constructs a new instance of this class. |

|                                                                                                                         Public methods                                                                                                                          ||
|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getDescription](https://developer.android.com/reference/kotlin/java/util/regex/PatternSyntaxException#getDescription())`()` Retrieves the description of the error.     |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)        | [getIndex](https://developer.android.com/reference/kotlin/java/util/regex/PatternSyntaxException#getIndex())`()` Retrieves the error index.                              |
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getPattern](https://developer.android.com/reference/kotlin/java/util/regex/PatternSyntaxException#getPattern())`()` Retrieves the erroneous regular-expression pattern. |

|                                                                                                                                                                                                    Properties                                                                                                                                                                                                    ||
|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | [message](https://developer.android.com/reference/kotlin/java/util/regex/PatternSyntaxException#message:kotlin.String) Returns a multi-line string containing the description of the syntax error and its index, the erroneous regular-expression pattern, and a visual indication of the error index within the pattern. |

## Public constructors

### PatternSyntaxException

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

```
PatternSyntaxException(
    desc: String!, 
    regex: String!, 
    index: Int)
```

Constructs a new instance of this class.

|                                                                               Parameters                                                                               ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `desc`  | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:A description of the error                                                  |
| `regex` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The erroneous pattern                                                       |
| `index` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The approximate index in the pattern of the error, or`-1`if the index is not known |

## Public methods

### getDescription

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

```
open fun getDescription(): String!
```

Retrieves the description of the error.

|                                                     Return                                                      ||
|-----------------------------------------------------------------------------------|------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | The description of the error |

### getIndex

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

```
open fun getIndex(): Int
```

Retrieves the error index.

|                                                                             Return                                                                             ||
|----------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The approximate index in the pattern of the error, or`-1`if the index is not known |

### getPattern

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

```
open fun getPattern(): String!
```

Retrieves the erroneous regular-expression pattern.

|                                                  Return                                                  ||
|-----------------------------------------------------------------------------------|-----------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | The erroneous pattern |

## Properties

### message

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

```
open val message: String?
```

Returns a multi-line string containing the description of the syntax error and its index, the erroneous regular-expression pattern, and a visual indication of the error index within the pattern.

|                                                   Return                                                   ||
|-----------------------------------------------------------------------------------|-------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | The full detail message |