Regular expressions support various modifiers to modify the characteristics of matches. Below are some commonly used modifiers and their usage:
^: The starting position for matching a string. For example, "^a" matches "a".
$: The end position of the string to match. For example, "$b" matches "b".
\nMatches any newline character. For example, "\n" matches "\n".
\tMatches any tab character. For example, "\t" matches "\t".
\sMatches any whitespace character. For example, "\s" matches "\s".
\wMatches any word character (including letters, digits, and underscores). For example, "\w" matches "\w".
\DMatches any non-digit character. For example, "\D" matches "\d".
\SMatches any non-word character. For example, "\S" matches "\s".
\xMatches any single octal character. For example, "\x20" matches "\x20".
\UMatches any Unicode character. For example, "\U0000ff" matches "\u0000ff".
\VMatches any vertical escape character. For example, "\V" matches "\v".
\QMatches any highlighted text. For example, "\Qthis is a test\E" matches "this is a test".
\EMatches any low-contrast text string. For example, "\Ethis is a test\Q" matches "this is a test".
The combined use of modifiers can be employed for more precise matching control. For example, one can use ^ 和 $ Use modifiers to match both the beginning and the end of a string, together. \n Modifiers to match any newline character, and so on.