What are regular expressions ?
A regular expression or regex is a sequence of characters which specifies a search pattern in a document. When a string follows this pattern we name it a match.
In this series of tutorials, we will use Sublime Text, a text editor rich in features, which support searching and replacing using regex. The current version of Sublime Text is 4. Sublime UI looks like following :
In order to bring up the search feature, do Ctrl+F on Windows or Cmd+F on Mac. The search feature looks as follows :
.* symbol is the feature for activating the search within Sublime Text with regular expressions
The text input area is where you type your regular expression
After typing the regular expression in the text input area, Sublime Text will search for matches of the regex and display them in its UI, using the following features :
here Sublime displays the number of occurences of the regex in the text, with the order of the current highlighted matched text
the current highlighted match
All matches are highlighted with a rectangle surrounding the match
A small window shows a minified version of the document at the top right of Sublime UI. It shows where matches are relative to the document. This is especially handy if the document is long. In this case, you just have to click an area in this minified window where the match is highlighted and Sublime will take you directly to the match in the document.
In the next tutorial, we will start looking into regex patterns. We will explore the different kinds of characters that compose a regex and how to combine them.