java.util.regex
Class Pattern

java.lang.Object
  extended by java.util.regex.Pattern
All Implemented Interfaces:
Serializable

public final class Pattern
extends Object
implements Serializable

Compiled regular expression ready to be applied.

Since:
1.4
See Also:
Serialized Form

Field Summary
static int CANON_EQ
           
static int CASE_INSENSITIVE
           
static int COMMENTS
           
static int DOTALL
           
static int MULTILINE
           
static int UNICODE_CASE
           
static int UNIX_LINES
           
 
Method Summary
static Pattern compile(String regex)
           
static Pattern compile(String regex, int flags)
           
 int flags()
           
 Matcher matcher(CharSequence input)
           
static boolean matches(String regex, CharSequence input)
           
 String pattern()
           
 String[] split(CharSequence input)
           
 String[] split(CharSequence input, int limit)
           
 String toString()
          Return the regular expression used to construct this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CANON_EQ

public static final int CANON_EQ
See Also:
Constant Field Values

CASE_INSENSITIVE

public static final int CASE_INSENSITIVE
See Also:
Constant Field Values

COMMENTS

public static final int COMMENTS
See Also:
Constant Field Values

DOTALL

public static final int DOTALL
See Also:
Constant Field Values

MULTILINE

public static final int MULTILINE
See Also:
Constant Field Values

UNICODE_CASE

public static final int UNICODE_CASE
See Also:
Constant Field Values

UNIX_LINES

public static final int UNIX_LINES
See Also:
Constant Field Values
Method Detail

compile

public static Pattern compile(String regex)
                       throws PatternSyntaxException
Parameters:
regex - The regular expression
Throws:
PatternSyntaxException - If the expression's syntax is invalid

compile

public static Pattern compile(String regex,
                              int flags)
                       throws PatternSyntaxException
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()

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

matcher

public Matcher matcher(CharSequence input)
Parameters:
input - The character sequence to be matched

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

pattern

public String pattern()

toString

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

Overrides:
toString in class Object
Returns:
the String representing this Object, which may be null
Since:
1.5
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)