Notes for Regex

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{\Ahttps?://}i
\A would match the exact beginning of a string, before Perl 4 it is ^

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 任何方式断行* (跨系统)
大写表示反义简写

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容