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( ); }
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access