Category of Characters
Explore the two main categories of characters in regular expressions: literal characters that match exact text and meta characters that carry special meanings for complex pattern matching. Understand case sensitivity, escaping meta characters, and how these distinctions enhance your ability to create powerful search patterns.
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.