Name
PatternSyntaxException
Synopsis
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( ); }
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.