const str = `
1. Bread
2. Apples
3. Milk
`;
const regex = /^\d\./gm;
console.log(str.match()); // [ '1.', '2.', '3.' ]
m
flag enables to match at the start and end of every line.
The regex matches lines that start with number followed by comma
Thanks for reading π
Follow @codedrops.tech for daily posts.
Instagram β Twitter β Facebook
Micro-Learning β Web Development β Javascript β MERN stack β Javascript
codedrops.tech
Top comments (0)