My Blog

My WordPress Blog

My Blog

My WordPress Blog

14. Java Regex

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, […]

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 […]

Scroll to top