您的当前位置:首页Notes for Regex

Notes for Regex

2024-12-13 来源:哗拓教育

Example 1
$_ = "yabba dabba doo";

Modifier

/i Case Insensitive
/s Match any character including newline
/x Allow meaningless whitespace in regex for easy reading, if matching literal space is required, use "/ " or \t or \s

if matching pound sign is required, use
/# or [#]

Choose a Character Interpretation

/a for ASCII
/u for Unicode
/l for local

Anchors

m{.png\z}i
\z would match the absolute end of a string, before Perl 4 it is $

m{.png\Z}i
\Z would allow newlines after.

m{\bfred\b}i
\b matches at either end of a word*. Word must only contain \w.

[0-9] \d
[A-Za-z0-9_] \w
[\f\t\n\r] \s
[\t ] \h
[\f\n\r] \v

\R 任何方式断行* (跨系统)
大写表示反义简写

显示全文