public final class Pattern extends Object
Modifier and Type | Field and Description |
---|---|
static int |
CASE_INSENSITIVE
Flag for comparisons independent of case.
|
protected int |
machine
Handle
|
Modifier and Type | Method and Description |
---|---|
static Pattern |
compile(String regex)
Creates a regex machine for the specified pattern.
|
static Pattern |
compile(String regex,
int flgs)
Creates a regex machine for the specified pattern and flag settings.
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
Matcher |
matcher(String string)
Creates a matcher on a given string for this regex machine.
|
static boolean |
matches(String regex,
String str)
Compiles the regular expression and attempts to match the string against it.
|
String |
pattern()
Returns the Regular Expression use to create this regex machine.
|
String[] |
split(String str)
Splits the provided string around matches with this regex machine.
|
String[] |
split(String str,
int limit)
Splits the provided string around matches with this regex machine.
|
String |
toString()
Returns a string representation of the object.
|
protected int machine
public static final int CASE_INSENSITIVE
public static Pattern compile(String regex)
regex
- patternpublic static Pattern compile(String regex, int flgs)
regex
- pattern to useflgs
- settingspublic String pattern()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object.
public Matcher matcher(String string)
string
- pattern to usepublic static boolean matches(String regex, String str)
regex
- regex patternstr
- string to be evaluatedpublic String[] split(String str)
str
- string to be split into tokenspublic String[] split(String str, int limit)
str
- string to be split into tokenslimit
- maximum number of tokensprotected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
The finalize
method in Object
does
nothing.