In this lesson we'll learn shorthands for common character classes as well as their negated forms. var str = `Afewserg, %8392 ?AWE`; var regex = /[a-zA-Z0-9]/g; // the same as: var regex = /\w/g; // Find anything but not the a-zA-Z0-9 var regex = /[^…
Regular Expression Character Classes define a group of characters we can use in conjunction with quantifiers. var str = `cat bat mat Hat 0at ?at`; var regex = /[bc]at/g; // match 'cat bat' // the same as: var regex = /(b|c)at/g; var regex = /[^bc]at/…
Boost.Regex provides three different functions to search for regular expressions 1. regex_match #include <boost/regex.hpp> #include <string> #include <iostream> int main() { std::string s = "Boost Libraries"; boost::regex expr(…
Using a character set repeated 1 or more times, make a pattern to search for strings that do not contain the characters 'a', 'e', 'i', 'o', 'u', and 'y'. /[^aeiouy]+/gi Next, surround our pattern with a word boundary on each side. /\b[^aeiouy]+\b/gi…
String to check: As it turns out, our potential shipmates are extremely superstitious. As such, we do not want anyone to enter certain words in their comments. Requirements: 1. Let's start checking for bad words within a sentence. We can begin with …