PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, PCRE_UNGREEDY, PCRE_EXTRA, PCRE_EXTENDED and PCRE_DUPNAMES and other mode modifier settings can be set inside the mode through a perl option character sequence. The syntax is: (? modifier). The available modifiers are:
Internal option letters
i for PCRE_CASELESS
m for PCRE_MULTILINE
s for PCRE_DOTALL
x for PCRE_EXTENDED
U for PCRE_UNG REEDY
X for PCRE_EXTRA
J for PCRE_INFO_JCHANGED
For example, (?im) setting indicates multi-line size Write insensitive matching. You can also use it to cancel these settings, for example (?im-sx) sets PCRE_CASELESS, PCRE_MULTILINE, but cancels PCRE_DOTALL and PCRE_EXTENDED at the same time. If a letter appears both before and after -, this option is unset.
When an option is at the top of the pattern (that is, not in a subgroup), the change will affect the rest of the pattern. For example, /ab(?i)c/ only matches "abc" and "abC". This form was changed in PCRE 4.0 (PHP 4.3.3). In previous versions, /ab(?i)c/ behaved exactly like /abc/i.
If an option is set in a subgroup, the impact is different. This is a variant of the behavior in perl 5.005. An option is set within a subgroup, changing only the remainder of the subgroup, so (a(?i)b)c only matches "abc" and "aBc" (assuming the PCRE_CASELESS option is not used). This means that options can have different effects at different locations in the pattern. Within the same submode, option settings for one branch propagate through to the remaining branches that follow. For example, (a(?i)b|c) matches "ab", "aB", "c" and "C". Although when matching "C" the first branch is discarded before the option is set. This is because the option settings are determined at compile time, otherwise it may cause very weird behavior.
PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can be changed in the same way as the perl compatibility options, using the letters U and X respectively. The (? The very beginning position.