Java Regex - Examples Matching Characters


Advertisements

Following are various examples of matching characters using regular expression in java.

Sr.No Construct & Matches
1 x

The character x

2 \\

The backslash character

3 \0n

The character with octal value 0n (0 ≤ n ≤ 7)

4 \0nn

The character with octal value 0nn (0 ≤ n ≤ 7)

5 \0mnn

The character with octal value 0mnn (0 ≤ m ≤ 3, 0 ≤ n ≤ 7)

6 \xhh

The character with hexadecimal value 0xhh

7 \uhhhh

The character with hexadecimal value 0xhhhh

8 \t

The tab character ('\u0009')

9 \n

The newline (line feed) character ('\u000A')

10 \r

The carriage-return character ('\u000D')

11 \f

The form-feed character ('\u000C')

Advertisements