August 2017
Beginner
298 pages
7h 4m
English
Regular expressions (RegExp) are basically a definition of a pattern (such as a sequence of characters, numbers, and so on) that can be searched within other text. For example, say you need to find all the words in a paragraph that start with the letter a. Then, in JavaScript, you define the pattern as:
const pattern = /^a+/
Regular expressions are always defined inside / /. In the preceding code snippet, we have the following:
This regular expression will match strings that start with the letter a. You can test these statements in: https://jsfiddle.net/. To test a string with this regular expression, do the following:
pattern.test('alpha') ...Read now
Unlock full access