Options for Perl Regular Expressions
Regular expressions can have options (also known as flags) that modify their behavior. Each engine supports a different set of options.
Option | Description | Backend value | Portable value |
---|
m | Multiline | multiline | multiline |
s | Single line | dotall | (not portable) |
i | Case-insensitive | ignorecase | ignorecase |
x | Extended with whitespace and comments | comment | comments |
p | Preserve matched strings | p | (not portable) |
g | Global match | global | (not portable) |
c | Keep current position | c | (not portable) |
a | Use ASCII charset rules | a | (not portable) |
d | Use default charset rules | d | (not portable) |
l | Use locale charset rules | l | (not portable) |
u | Use Unicode charset rules | u | (not portable) |
When m
and s
together, .
matches any char including newlines but ^
and $
match lines.