java.util.regex
Class Pattern
java.lang.Object
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
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
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 expressionflags
- 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 expressioninput
- 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 matchedlimit
- 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)