String.prototype.match()
String.prototype.match() is a JavaScript method in the String category. Retrieves matches of a string against a regular expression. The syntax is str.match(regexp). A typical example: "Hello 123".match(/\d+/) // ["123"]. Another practical use — Extract all matches: const text = 'Contact: alice@test.com, bob@test.com' const emails = text.match(/[\w.]+@[\w.]+/g) console.log(emails) // ['alice@test.com', 'bob@test.com'] Its time complexity is O(n), which matters when it runs over large inputs. The TypeScript signature is (regexp: string | RegExp): RegExpMatchArray | null. Common pitfall — Without global flag returns different structure. Without /g flag, match() returns an array with the full match and capturing groups. With /g, only full matches are returned (no groups). A close sibling is String.prototype.charAt(), which returns the character at the specified index. A close sibling is String.prototype.charCodeAt(), which returns the Unicode value of the character at the specified index. A close sibling is String.prototype.concat(), which concatenates strings together. A close sibling is String.prototype.includes(), which checks if a string contains a specified substring.