Java Regular Expression Tutorial - Java Regular Expression








A regular expression describes a pattern in a sequence of characters. A regular expression is a string that describes a character sequence.

We can then use pattern to

  • validate the sequence of characters
  • search through the sequence of characters
  • replace the characters matching the pattern




Package

The java.util.regex package supports regular expression processing.

The general description in a regular expression called a pattern, can be used to find matches in other character sequences.

Regular expressions can specify wildcard characters, sets of characters, and various quantifiers.

We can specify a regular expression that represents a general form that can match several different specific character sequences.

There are two classes that support regular expression processing: Pattern and Matcher.

These classes work together: use Pattern to define a regular expression. and match the pattern against another sequence using Matcher.