Open mancuoj opened 2 months ago
The character or word we want to find is written directly.
.
: Any CharacterThe period .
allows selecting any character, including special characters and spaces.
[abc]
If one of the character in a word can be various characters, we write it in square brackets []
with all alternative characters.
[^abc]
[a-z]
To find letters in the specified range, the starting letter and the ending letter are written in square brackets []
with dash between them -
. It is case-intensive.
[0-9]
*
We put an asterisk *
after a character to indicate that the character may either not match at all or can match many times.
+
To indicate that a character can occur one or more times, we put a plus sign +
after a character.
?
To indicate that a character is optional, we put a ?
question mark after a character.
To express a certain number of occurrences of a character, at the end we write curly braces {n}
along with how many times we want it to occur.
To express at least a certain number of occurrences of a character, immediately after the character we write at least how many times we want it to occur in a row followed by a comma , and wrapped inside curly braces {n, }
.
To express the occurrence of a character in a certain number range, we write curly braces {x,y}
for the inclusive interval.
Regex, aka Regular Expression. It helps to match, find or manage text.