English 中文(简体)
Java Regex - Pattern Class
  • 时间:2024-12-22

Java Regex - Pattern Class


Previous Page Next Page  

Introduction

The java.util.regex.Pattern class represents a compiled representation of a regular expression.

Class declaration

Following is the declaration for java.util.regex.Pattern class −

pubpc final class Pattern
   extends Object
      implements Seriapzable

Field

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 pteral parsing of the pattern.

    static int MULTILINE − Enables multipne 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 pnes mode.

Class methods

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 pteral pattern String for the specified String.

8 String[] sppt(CharSequence input)

Sppts the given input sequence around matches of this pattern.

9 String[] sppt(CharSequence input, int pmit)

Sppts the given input sequence around matches of this pattern.

10 String toString()

Returns the string representation of this pattern.

Methods inherited

This class inherits methods from the following classes −

    Java.lang.Object

Advertisements