Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 877
نمايش فراداده

PatternSyntaxExceptionjava.util.regex

Java 1.4serializable unchecked

Signals a syntax error in the text representation of a regular expression. An exception of this type may be thrown by the Pattern.compile( ) and Pattern.matches( ) methods, and also by the String matches( ), replaceFirst( ), replaceAll( ) and split( ) methods which call those Pattern methods.

getPattern( ) returns the text that contained the syntax error, and getIndex( ) returns the approximate location of the error within that text, or -1, if the location is not known. geTDescription( ) returns an error message that provides further detail about the error. The inherited getMessage( ) method combines the information provided by these other three methods into a single multiline message.

Figure 16-133. java.util.regex.PatternSyntaxException

public class

PatternSyntaxException extends IllegalArgumentException { // Public Constructors public

PatternSyntaxException (String

desc , String

regex , int

index ); // Public Instance Methods public String

getDescription ( ); public int

getIndex ( ); public String

getPattern ( ); // Public Methods Overriding Throwable public String

getMessage ( ); }