Category: 14. Java Regex
-
Examples of Logical Operators
Following are various examples of Logical Operators using regular expression in java. Sr.No Construct & Matches 1 XYX followed by Y. 2 X|YEither X or Y.
-
Examples of Possessive Quantifiers
A possessive quantifier is similar to greedy quantifier. It indicates the engine to start by checking the entire string.It is different in the sense if it doesn’t work, if match failed and there is no looking back. Following are various examples of Possessive Quantifiers using regular expression in java. Sr.No Construct & Matches 1 X?+X,…
-
Examples of Reluctant Quantifiers
A reluctant quantifier indicates the search engine to start with the shortest possible piece of the string. Once match found, the engine continue; otherwise it adds one character to the section of the string being checked and search that, and so on. This process follows until it finds a match or the entire string has…
-
Java Regexs of Greedy Quantifiers
A greedy quantifier indicates to search engine to search the entire string and check whether it matches the given regexp. Following are various examples of Greedy Quantifiers using regular expression in java. Sr.No Construct & Matches 1 X?X, once or not at all. 2 X*X, zero or more times 3 X+X, one or more times.…
-
Examples of Boundary Matchers
Following are various examples of Boundary Matchers using regular expression in java. Sr.No Construct & Matches 1 ^The beginning of a line. 2 $The end of a line. 3 \bA word boundary. 4 \BA non-word boundary. 5 \AThe beginning of the input. 6 \GThe end of the previous match. 7 \ZThe end of the input…
-
Unicode Character Classes
Following are various examples of matching Unicode character classes using regular expression in java. Sr.No Construct & Matches 1 \p{IsLatin}A Latin script character. 2 \p{InGreek}A character in the Greek block. 3 \p{Lu}An uppercase letter. 4 \p{IsAlphabetic}An alphabetic character (binary property). 5 \p{Sc}A currency symbol. 6 \P{InGreek}Any character except one in the Greek block. 7 [\p{L}&&[^\p{Lu}]]Any…
-
JAVA Character Classes
Following are various examples of matching JAVA character classes using regular expression in java. Sr.No Construct & Matches 1 \p{javaLowerCase}Equivalent to java.lang.Character.isLowerCase(). 2 \p{javaUpperCase}Equivalent to java.lang.Character.isUpperCase(). 3 \p{javaWhitespace}Equivalent to java.lang.Character.isWhitespace(). 4 \p{javaMirrored}Equivalent to java.lang.Character.isMirrored().
-
POSIX Character Classes
Following are various examples of matching POSIX character classes using regular expression in java. Sr.No Construct & Matches 1 \p{Lower}A lower-case alphabetic character: [a-z]. 2 \p{Upper}An upper-case alphabetic character:[A-Z]. 3 \p{ASCII}All ASCII:[\x00-\x7F]. 4 \p{Alpha}An alphabetic character:[\p{Lower}\p{Upper}]. 5 \p{Digit}A decimal digit: [0-9]. 6 \p{Alnum}An alphanumeric character:[\p{Alpha}\p{Digit}]. 7 \p{Punct}Punctuation: One of !”#$%&'()*+,-./:;<=>?@[\]^_>{|}<. 8 \p{Graph}A visible character: [\p{Alnum}\p{Punct}].…
-
Predefined Character Classes
Following are various examples of matching predefined character classes using regular expression in java. Sr.No Construct & Matches 1 .Any character (may or may not match line terminators). 2 \dA digit: [0-9]. 3 \DA non-digit: [^0-9]. 4 \sA whitespace character: [ \t\n\x0B\f\r] 5 \SA non-whitespace character: [^\s]. 6 \wA word character: [a-zA-Z_0-9]. 7 \WA non-word…
-
Matching Character Classes
Following are various examples of matching character classes using regular expression in java. Sr.No Construct & Matches 1 [abc]a, b, or c (simple class). 2 [^abc]Any character except a, b, or c (negation). 3 [a-zA-Z]a through z or A through Z, inclusive (range). 4 [a-d[m-p]]a through d, or m through p: [a-dm-p] (union). 5 [a-z&&[def]]d,…