JavaScript Internals (521 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)
What are modifiers in regular expression
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
var text = "Learn JS one by one";
var pattern = /one/g;
var result = text.match(pattern); // one,one