Embed presentation
Download to read offline



![IGNORING CASE:
Using the i flag for case insensitivity
const caseInsensitiveRegex = /ignore case/i;
const testString =
'We use the i flag to iGnOrE CasE';
caseInsensitiveRegex.test(testString); // true
MATCHING ANY CHARACTER:
Using the wildcard character . as a placeholder
// To match "cat", "BAT", "fAT", "mat"
const regexExpr = /.at/gi;
const testString = "cat BAT cupcake fAT mat dog";
const allMatchingWords =
testString.match(regexExpr);
// ["cat", "BAT", "fAT", "mat"]](https://image.slidesharecdn.com/bmsywvfqbmycskxsvqiq-signature-a5ab5a31bdc3bb4e06c4de1cbf5cfc5828ead120eb0fdbe7b1c86ebec3552ab4-poli-200609033517/85/Regex-cheatsheet-part-1-4-320.jpg)

This document provides a regex cheat sheet with examples of how to test regular expressions, match multiple patterns using the OR operator, ignore case using the i flag, and match any character using a wildcard placeholder. It demonstrates testing a regex for a match, using | to match yes, no, or maybe, ignoring case with the i flag, and using . as a placeholder to match words ending in at.



![IGNORING CASE:
Using the i flag for case insensitivity
const caseInsensitiveRegex = /ignore case/i;
const testString =
'We use the i flag to iGnOrE CasE';
caseInsensitiveRegex.test(testString); // true
MATCHING ANY CHARACTER:
Using the wildcard character . as a placeholder
// To match "cat", "BAT", "fAT", "mat"
const regexExpr = /.at/gi;
const testString = "cat BAT cupcake fAT mat dog";
const allMatchingWords =
testString.match(regexExpr);
// ["cat", "BAT", "fAT", "mat"]](https://image.slidesharecdn.com/bmsywvfqbmycskxsvqiq-signature-a5ab5a31bdc3bb4e06c4de1cbf5cfc5828ead120eb0fdbe7b1c86ebec3552ab4-poli-200609033517/85/Regex-cheatsheet-part-1-4-320.jpg)