Match Single Character with Multiple Possibilities, freeCodeCamp Regex Concepts and Challenges

Lesson Summary

In this lesson, we look at matching single characters that may have multiple possibilities. This allows us to specify a pattern within a literal pattern we specify. The example we go over explains that, if we wanted to batch the words "bag", "big", and "bug", but not the word "bog", we can ultimately do so using the regex "/b[aiu]g/". This regex would allow us to specify the 3 words and would exclude "bog" since we do not specify the letter "o" within the square brackets of our regular expression. Understanding and using this in combination with the other tools we have learned thus far gives us the ability to find a plethora of patterns within massive datasets. Practicing implementing regular expressions is key in the mastery of the endeavor. Learning about regular expressions is best accomplished with regular practice or syntax easily becomes cryptic. But once the concept is understood, google is only a click away.

Subscribe To Monthly Newsletter. Chance to Win Monthly Prizes

* indicates required