Pattern-matching modifiers
The regular expression syntax has Perl-like extensions. The pattern-matching modifiers are extensions that can be used to control the matching process in more detail.
The modifiers are enabled with (?<modifiers>
) and disabled with a minus (?-<modifiers>
), where <modifiers>
is a list of one or more modifiers.
Example of pattern-matching modifiers
# This fingerprint is identical to the special character sequence example,
# except for the (?i) modifier.
# HTTP Header names are case-insensitive. For this reason,
# case-insensitivity is enabled in this fingerprint.
(?i)Content-Length: \d\d\d\d\d
The modifiers (?C
), (?L
), and (?s
)are enabled by default.
The pattern-matching modifiers are listed in the following table:
Sequence | Description |
---|---|
(?i)
|
Case insensitive mode When enabled, case insensitive matching is used for the uppercase and lowercase letters. Thus, a letter matches regardless of its capitalization. When disabled, the letters are matched case-sensitively so that capitalization is taken into account in the matching process. |
(?s)
|
Single line mode When enabled, the dot character "." matches also the null character When disabled, the linefeed or a missing character are not matched. This modifier is enabled by default. Use |
(?x)
|
Extended readability mode When enabled, equals to enabling When disabled, equals to disabling |
(?C)
|
Allow comments mode When enabled, anything after the hash character "# " is regarded as a comment and not included in the matching process. When disabled, the hash character "# " and anything following are used in the matching process. This modifier is enabled by default. Use |
(?L)
|
Ignore linefeeds mode When enabled, linefeed and carriage return characters are not included in the matching process unless defined ( When disabled, linefeeds and carriage returns are used in the matching process. This modifier is enabled by default. Use |
(?S)
|
Ignore spaces mode When enabled, the space and horizontal tab characters are not used in the matching process unless defined ( When disabled, the space and horizontal tab characters are used in the matching process. |
|
Applies the These modifiers are not used in other parts of the regular expression. |