DEV Community

Mehul Lakhanpal
Mehul Lakhanpal

Posted on • Originally published at codedrops.tech

2 2

Multiline flag in regex

const str = `
1. Bread
2. Apples
3. Milk
`;

const regex = /^\d\./gm;
console.log(str.match()); // [ '1.', '2.', '3.' ]
Enter fullscreen mode Exit fullscreen mode

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.

InstagramTwitterFacebook

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript

codedrops.tech

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay