-
Notifications
You must be signed in to change notification settings - Fork 280
Regular Expressions
A regular expression (or "regex") is a sequence of characters that is used to match a longer list of characters.
For example, this is a regular expression:
[df]og
which matches the words dog and fog.
You can use different combination of symbols in order to match different sets of characters.
"match" means "there is/are one or more matches in the text".
For example, let's take this text:
"There's a dog running in the fog."
regex 1:
dog
matches: 1
This regex matches the text.
regex 2
[df]og
matches: 2
This regex matches the text.
regex 3
rain
matches: 0
This regex doesn't match the text.
Square brackets are used whenever you want to establish an "OR" relation between what's inside them.
For example
[ab]
matches "a" and "b".
This regex:
file[01234]
will match
- file0
- file1
- file2
- file3
- file4
Francesco Andreuzzi, Italy, andreuzzi.francesco@gmail.com