java.util.regex

Class Pattern

public final class Pattern extends Object implements Serializable

Compiled regular expression ready to be applied.

Since: 1.4

Field Summary
static intCANON_EQ
static intCASE_INSENSITIVE
static intCOMMENTS
static intDOTALL
static intMULTILINE
static intUNICODE_CASE
static intUNIX_LINES
Method Summary
static Patterncompile(String regex)
static Patterncompile(String regex, int flags)
intflags()
Matchermatcher(CharSequence input)
static booleanmatches(String regex, CharSequence input)
Stringpattern()
String[]split(CharSequence input)
String[]split(CharSequence input, int limit)
StringtoString()
Return the regular expression used to construct this object.

Field Detail

CANON_EQ

public static final int CANON_EQ

CASE_INSENSITIVE

public static final int CASE_INSENSITIVE

COMMENTS

public static final int COMMENTS

DOTALL

public static final int DOTALL

MULTILINE

public static final int MULTILINE

UNICODE_CASE

public static final int UNICODE_CASE

UNIX_LINES

public static final int UNIX_LINES

Method Detail

compile

public static Pattern compile(String regex)

Parameters: regex The regular expression

Throws: PatternSyntaxException If the expression's syntax is invalid

compile

public static Pattern compile(String regex, int flags)

Parameters: regex The regular expression flags The match flags, a bit mask

Throws: PatternSyntaxException If the expression's syntax is invalid IllegalArgumentException If bit values other than those corresponding to the defined match flags are set in flags

flags

public int flags()

matcher

public Matcher matcher(CharSequence input)

Parameters: input The character sequence to be matched

matches

public static boolean matches(String regex, CharSequence input)

Parameters: regex The regular expression input The character sequence to be matched

Throws: PatternSyntaxException If the expression's syntax is invalid

pattern

public String pattern()

split

public String[] split(CharSequence input)

Parameters: input The character sequence to be matched

split

public String[] split(CharSequence input, int limit)

Parameters: input The character sequence to be matched limit The result threshold

toString

public String toString()
Return the regular expression used to construct this object.

Since: 1.5

UNKNOWN: Prior to JDK 1.5 this method had a different behavior