Multiline flag in regex
Mehul Lakhanpal
Posted on April 12, 2021
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
💖 💪 🙅 🚩
Mehul Lakhanpal
Posted on April 12, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.