Category of Characters

Learn about the types of characters in RegEx.

We'll cover the following

Generally, there are two categories of characters.

  • Literal Characters: A character with the same meaning.
  • Meta Characters: A character with special meaning.

Literal character

In a RegEx, the simplest match is a literal match. Literal, as the name suggests, matches two or more objects with exact properties:

  • Case sensitive by default.
  • “A” matches “A”, and “a” matches “a”, and so on.
  • Consist of A-Z a-z 0-9 _ (uppercase alphabets, lowercase alphabets, numbers from zero to nine, and underscore).

Meta character

To match complex text or patterns, we use some special characters. Special characters have different meanings.

  • Each character has a special meaning.
  • More than one meaning is possible.
  • Consists of [ ] ( ) { } + - \ * . ^ ! = $ : | ?

Note: To use meta-characters as literal characters, use the backslash \ to escape them. /\./ now dot will act as a literal character.

Magic character