You may have already noticed that matching is case sensitive. This means that the regular expression will only match a substring if both the regular expression and the substring have the same upper/lowercase characters.
In order to make matching case insensitive, you need to use a modifier. Regular expression modifiers allow you to change the default behavior of the matching.
To add a modifier, you extend the basic syntax of the regular expression as follows:
'/regular expression/modifier(s)'
Each modifier is just a single character that is specified between the last slash and the quote. The modifier for insensitive case matching is
i. So, the following regular expression matches Hello, hello, HeLlO, and hELLO:
'/hello/i'
Some other modifiers are listed in the following table:
| Modifier |
Meaning |
| i |
Searches in a case insensitive manner. |
| g |
Matches the regular expression as many times as possible. Matches all substrings globally. |
| s |
Treats the string as a single line. |
| m |
Treats the string as multiple lines. |
More than one modifier can be used at the same time.