What do the common regular expression methods do?
There are four worth knowing, and they differ in what they return. The test method returns a boolean. The match method returns an array of matches, or the first match with capture groups when the pattern has no global flag. The matchAll method returns an iterator over every match, which is the modern replacement for the global match method. The replace and replaceAll methods substitute matched text.
const text = "order-1234, order-5678";
console.log(text.match(/\d+/g)); // ["1234", "5678"]
console.log(text.match(/\d{4}/)); // ["1234", "5678"] - first match only
console.log(text.replace(/\d+/g, "#")); // "order-####, order-####"
console.log(text.split(/,\s*/)); // ["order-1234", "order-5678"]
console.log(/^order/.test(text)); // true
console.log(/\d{5}/.test(text)); // falseThe difference between match with and without the global flag catches people out. Without the flag, match returns an array where the first element is the whole match and the rest are the capture groups. With the flag, it returns an array of the full matches only, with no group information. If you want the groups from every match, use matchAll, which always gives you the full match plus the groups for each one.
The split method is also more useful with a pattern than people realise. Splitting on a regular expression matching any run of whitespace is a better way to normalise a sentence than splitting on a single space, because it also handles tabs and repeated spaces without producing empty strings.
One last thing about the replace method. With a string pattern it replaces only the first match, while with a regular expression it replaces only the first match too unless you add the global flag. The replaceAll method always replaces everything, and it also accepts a regular expression, in which case the global flag is not needed.