Class Pattern
java.util.regex.Pattern for the Codename One runtime: a backtracking
matcher written for this module, with the JDK's syntax and the JDK's
answers for the constructs it has.
Supported
- Literals,
., and every escape for a character:\t \n \r \f \a \e,\0nn,\xhh,\x{h...}, backslash-u with four hex digits,\cX, and\Q...\E. - Character classes with ranges, negation, nested unions and
&&intersections;\d \D \w \W \s \S \h \H \v \V;\R. - The POSIX classes (
\p{Alpha},\p{Punct}, ...), thejava...classes, and the Unicode propertiesL,Lu,Ll,N/Nd,IsAlphabetic,IsLetter,IsDigit,IsUppercase,IsLowercase,IsWhite_Space. - Unicode scripts (
\p{IsGreek},\p{script=Latn}), blocks (\p{InGreek},\p{block=Arrows}) and general categories (\p{Sc},\p{IsPd},\p{gc=Mn}), from the Unicode 15.0 tables ofUnicodeTables. - The binary properties
IsDigit,IsPunctuation,IsTitlecase,IsControl,IsAssigned,IsHex_Digit,IsJoin_Control,IsNoncharacter_Code_Point,IsWord,IsAlnum,IsBlank,IsGraphandIsPrint, in any case. \p{all}, any code point.UNICODE_CHARACTER_CLASS((?U)):\d \w \s \band the POSIX classes take their Unicode definitions, as on the JDK.- Greedy, reluctant and possessive quantifiers.
- Capturing, non-capturing and named groups, back references by number and by name, alternation, atomic groups.
- Lookahead and bounded lookbehind, positive and negative.
^ $ \A \z \Z \G \b \B.CASE_INSENSITIVE,MULTILINE,DOTALL,COMMENTS,LITERAL,UNIX_LINESandUNICODE_CASE, as arguments and inline ((?i),(?i:...),(?-i)).
Refused
These throw PatternSyntaxException (the flags an
UnsupportedOperationException) naming the construct, when the pattern
is compiled. Nothing is accepted and then matched differently.
- Other binary properties (
\p{IsEmoji},\p{IsIdeographic}, ...). \X,\N{name},\b{g}.CANON_EQ.
Differences
Text is matched one code point at a time, as on the JDK: . and a
character class take a whole surrogate pair. The Unicode properties and
categories answer from the tables, for all of Unicode; javaLetter and
its kin answer this class's own letter test, the scripts a device font is
likely to have. A group repeated many thousand times
over a long text recurses once for each repetition, as the JDK's does,
on a stack that is smaller on a device.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic Patternstatic Patternintflags()matcher(CharSequence input) static booleanmatches(String regex, CharSequence input) pattern()static StringA pattern that matchessand nothing else.String[]split(CharSequence input) String[]split(CharSequence input, int limit) Splitsinputaround the matches of this pattern, by the JDK's rules forlimit.splitAsStream(CharSequence input) The piecessplit(CharSequence)would answer, found one at a time as the stream asks for them, as the JDK's are: the search starts on the first request, so alimitstops it and a change to a mutable input before then is seen.toString()Returns a string representation of the object.
-
Field Details
-
UNIX_LINES
public static final int UNIX_LINES- See Also:
-
CASE_INSENSITIVE
public static final int CASE_INSENSITIVE- See Also:
-
COMMENTS
public static final int COMMENTS- See Also:
-
MULTILINE
public static final int MULTILINE- See Also:
-
LITERAL
public static final int LITERAL- See Also:
-
DOTALL
public static final int DOTALL- See Also:
-
UNICODE_CASE
public static final int UNICODE_CASE- See Also:
-
CANON_EQ
public static final int CANON_EQ- See Also:
-
UNICODE_CHARACTER_CLASS
public static final int UNICODE_CHARACTER_CLASS- See Also:
-
-
Method Details
-
compile
-
compile
-
pattern
-
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the 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. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode()) -
flags
public int flags() -
matcher
-
matches
-
split
-
split
Splitsinputaround the matches of this pattern, by the JDK's rules forlimit. -
splitAsStream
The piecessplit(CharSequence)would answer, found one at a time as the stream asks for them, as the JDK's are: the search starts on the first request, so alimitstops it and a change to a mutable input before then is seen. -
quote
-
asPredicate
-
asMatchPredicate
-