The java.util.regex.Pattern class represents a compiled representation of a regular expression.
Following is the declaration for java.util.regex.Pattern class −
public final class Pattern extends Object implements Serializable
Following are the fields for java.util.regex.Duration class −
static int CANON_EQ − Enables canonical equivalence.
static int CASE_INSENSITIVE − Enables case-insensitive matching.
static int COMMENTS − Permits whitespace and comments in pattern.
static int DOTALL − Enables dotall mode.
static int LITERAL − Enables literal parsing of the pattern.
static int MULTILINE − Enables multiline mode.
static int UNICODE_CASE − Enables Unicode-aware case folding.
static int UNICODE_CHARACTER_CLASS − Enables the Unicode version of Predefined character classes and POSIX character classes.
static int UNIX_LINES − Enables Unix lines mode.
Sr.No | Method & Description |
---|---|
1 | static Pattern compile(String regex)
Compiles the given regular expression into a pattern. |
2 | static Pattern compile(String regex, int flags)
Compiles the given regular expression into a pattern with the given flags. |
3 | int flags()
Returns this pattern's match flags. |
4 | Matcher matcher(CharSequence input)
Creates a matcher that will match the given input against this pattern. |
5 | static boolean matches(String regex, CharSequence input)
Compiles the given regular expression and attempts to match the given input against it. |
6 | String pattern()
Returns the regular expression from which this pattern was compiled. |
7 | static String quote(String s)
Returns a literal pattern String for the specified String. |
8 | String[] split(CharSequence input)
Splits the given input sequence around matches of this pattern. |
9 | String[] split(CharSequence input, int limit)
Splits the given input sequence around matches of this pattern. |
10 | String toString()
Returns the string representation of this pattern. |
This class inherits methods from the following classes −