Strings In Depth16 / 18
Up next

Match a pattern

const text = "order-42-shipped";
// match returns the matches, or null when nothing matches
const m: RegExpMatchArray | null = text.match(/\d+/);
console.log(m ? m[0] : "no number");
What you're solving

match returns RegExpMatchArray | null