Java Regex - Examples of Boundary Matchers


Following are various examples of Boundary Matchers using regular expression in java.

S.N. Construct & Matches
1 ^

The beginning of a line.

2 $

The end of a line.

3 \b

A word boundary.

4 \B

A non-word boundary.

5 \A

The beginning of the input.

6 \G

The end of the previous match.

7 \Z

The end of the input but for the final terminator, if any.

8 \z

The end of the input.