Specify Upper and Lower Number of Matches, freeCodeCamp Coding for Beginners 2021

preview_player
Показать описание
In this regular expression lesson from freeCodeCamp's regex course, we take a look at the ability to specify the upper and lower number of matches using curly braces. WIthin curly braces we are able to specify 2 numbers, the left number specifying the lowest number of patterns it should match, and the number on the right would match the upper number of patterns. So we can specify our regex to return "aaah" and "aaaah" but not "aah" using the regular expression /a{3,5}h/ This is because it can only match cases where there are 3-5 letter "a"s. If there is more or less than 3-5 then it will not match the pattern.

Рекомендации по теме