By default, the comparison of an input string with any literal characters in a regular expression pattern is case sensitive. This and several other aspects of default regular expression behaviour can be modified by specifying regular expression options i.e. Matching modes. Usually they are specified outside the regular expression. Common matching modes are
- Case Insensitivity (i) – Case-insensitive matching.
- Multiline (m) – Use multiline mode, where ^ and $ match the beginning and end of each line (instead of the beginning and end of the input string).
- Single line (s) – Use single-line mode, where the period (.) matches every character (instead of every character except \n).
- Dot Matches All (s) – By default, the dot . doesn’t match line break characters such as line feeds and carriage returns. This mode is sometimes called single-line (hence the s) because as far as the dot is concerned, it turns the whole string into one big line—.* will match from the first character to the last, no matter how many line breaks stand in between.
- Global Matching (g) – Find all matches, rather than only the first one.