JS Coding Questions Logo
JS Coding Questions
#157💼 Interview💻 Code

What are modifiers in regular expression

Advertisement

728x90

Modifiers can be used to perform case-insensitive and global searches. Let's list some of the modifiers,

| Modifier | Description |

| -------- | ------------------------------------------------------- |

| i | Perform case-insensitive matching |

| g | Perform a global match rather than stops at first match |

| m | Perform multiline matching |

Let's take an example of global modifier,

javascript
1var text = "Learn JS one by one";
2
3var pattern = /one/g;
4
5var result = text.match(pattern); // one,one

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 72

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
157of476