Insert a Regex Token to Change a Matching Mode
The Insert Token button on the Create panel makes it easy to insert the following regular expression tokens to change how the regular expression engine applies your regular expression. These tokens are called mode modifiers.

Mode modifiers are useful in situations where you can’t set overall matching modes like you can with the combo boxes on RegexBuddy’s toolbar. Mode modifiers are not supported by all applications that support matching modes. But in applications that do, mode modifiers always override modes set outside of the regex (combo boxes in RegexBuddy).
A mode modifier can change multiple options at the same time. The Mode Modifiers item in the Insert Token menu pops up a dialog box that shows all available options.
First, you need to choose whether the options you want to set should affect the whole regular expression, only the remainder of the regular expression, or only the contents of a group. Some of these choices may not be available, depending on your application’s regex flavor. A mode modifier for the whole regex can either include only those options that are changed from those set outside of the regex, or it can include all options to make the regex independent of the options set outside the regex.
The dialog box always shows all options that can be toggled via mode modifiers by some of the flavors that RegexBuddy supports. Those not supported by your application’s regex flavor are grayed out. Options that can be set outside the regex but for which no flavor has mode modifiers are not shown.
The checkboxes always positive labels to indicate the options they activate. To make the regex case sensitive, for example, you always tick the “case sensitive” checkbox, regardless of whether your regex flavor uses (?c) to turn on case sensitivity, or (?-i) to turn off case insensitivity. This avoids confusion when switching between regex flavors that have opposite options and avoids double negations such as “case insensitive off”.
Options that are already active, because they’re set by a preceding mode modifier or by options external to the regex, or simply because they’re the default options, are indicated by checkboxes in an “indeterminate” state. These checkboxes have either a square or a dash inside of them, depending on the theme or your version of Windows. Clicking on those options has no effect. RegexBuddy doesn’t let you add redundant mode modifiers. To turn off an option you need to turn on the opposite option.
Options that are not active have clear checkboxes. You can set those by clicking the checkbox. Click it again if you change your mind.
These options are available:
- Free-spacing syntax: Unescaped literal spaces and line breaks in the regex that are not inside a character class are ignored so you can use them to format your regex to make it more readable. In most applications this mode also makes # the start of a comment that runs until the end of the line. Unescaped literal whitespace inside character classes does still add that whitespace to the character class.
- ... also in character classes: Free-spacing mode that also ignores whitespace inside character classes. Only a few regex flavors support this.
- Exact spacing syntax: Unescaped spaces, line breaks, and # characters in the regex are treated as literal characters that the regex must match.
- Case insensitive: Differences between uppercase and lowercase characters are ignored. cat matches CAT, Cat, or cAt or any other capitalization in addition to cat.
- Case sensitive: Differences between uppercase and lowercase characters are significant. cat matches only cat.
- Dot matches line breaks: The dot matches absolutely any character, whether it is a line break character or not. Sometimes this option is called “single line mode”.
- Dot doesn’t match line breaks: The dot matches any character that is not a line break character. Which characters are line break characters depends on the application and the line break mode.
- ^$ match at line breaks: The ^ and $ anchors match after and before line breaks, or at the start and the end of each line in the subject string. Which characters are line break characters depends on the application and the line break mode. Sometimes this option is called “multi-line mode”.
- ^$ don’t match at line breaks: The ^ and $ anchors only match at the start and the end of the whole subject string. Depending on the application, $ may still match before a line break at the very end of the string.
- LF-only line break handling: The dot and anchors recognize only the line feed character \n as a line break.
- Default line break handling: The dot and anchors recognize the characters they normally do as line breaks.
- Allow duplicate names: Multiple named capturing groups in the regular expression are allowed to have the same name. How backreferences to shared names are treated depends on the application.
- Names must be unique: All named capturing groups in the regular expression must have a unique name. Groups with the same name are treated as an error.
- Lazy quantifiers: Quantifiers are lazy by default. Adding a question mark makes them greedy. So a* is lazy and a*? is greedy.
- Greedy quantifiers: Quantifiers are greedy by default. If the application supports lazy quantifiers, then adding a question mark makes quantifiers lazy. So a* is greedy and a*?, if supported, is lazy.
- Unsupported escaped letters are errors: Escaped letters that do not form a regex token are an error.
- Letters can be escaped: Escaped letters that do not form a special regex token match the letter.
- ASCII case folding: If the regex is case insensitive then only ASCII letters are compared case insensitively; it remains case sensitive for non-ASCII letters.
- Unicode case folding: If the regex is case insensitive then it uses Unicode case folding so that most letters are compared case insensitively. We say “most” letters because Unicode case folding rules are complicated and many applications don’t follow them exactly, which may affect letters that aren’t part of a one-on-one uppercase and lowercase pair.
- Default case folding: Case insensitivity may or may not affect non-ASCII characters, depending on what the application does by default.
- ASCII character classes: Shorthand and POSIX character classes can only match ASCII characters.
- Unicode character classes: Shorthand and POSIX character classes include Unicode characters.
- Default character classes: Shorthand and POSIX character classes may be ASCII-only or may include Unicode characters, depending on what the application does by default.
- POSIX Basic flavor: Interpret the regex as a POSIX basic regular expression.
- POSIX Extended flavor: Interpret the regex as a POSIX extended regular expression.
- Treat regex as literal text: Interpret the regex (minus the leading mode modifier) as literal text.