Author: saqibkhan

  • 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,…

  • Examples Matching Characters

    Following are various examples of matching characters using regular expression in java. Sr.No Construct & Matches 1 xThe character x 2 \\The backslash character 3 \0nThe character with octal value 0n (0 ≤ n ≤ 7) 4 \0nnThe character with octal value 0nn (0 ≤ n ≤ 7) 5 \0mnnThe character with octal value 0mnn…

  • PatternSyntaxException 

    Introduction The java.util.regex.PatternSyntaxException class represents a unchecked exception thrown to indicate a syntax error in a regular-expression pattern. Class declaration Following is the declaration for java.util.regex.PatternSyntaxException class − Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career. Constructors Sr.No Method & Description 1 PatternSyntaxException(String desc, String regex, int index)Constructs a…

  • Matcher Class

    Introduction The java.util.regex.Matcher class acts as an engine that performs match operations on a character sequence by interpreting a Pattern. Class declaration Following is the declaration for java.util.regex.Matcher class − Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career. Class methods Sr.No Method & Description 1 Matcher appendReplacement(StringBuffer sb, String…