文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>perl Pattern Matching

perl Pattern Matching

时间:2007-06-25  来源:ilovit

Modifier Meaning
i Do case-insensitive pattern matching.
m

Treat string as multiple lines (^ and $ match internal \n).

s

Treat string as single line (^ and $ ignore \n, but . matches \n).

x

Extend your pattern's legibility with whitespace and comments.

 
Assertion Meaning
^

Matches at the beginning of the string (or line, if /m used)

$

Matches at the end of the string (or line, if /m used)

\b

Matches at word boundary (between \w and \W)

\B

Matches except at word boundary

\A

Matches at the beginning of the string

\Z

Matches at the end of the string

\G

Matches where previous m//g left off

(?=...)

Matches if engine would match ... next

(?!...)

Matches if engine wouldn't match ... next

 
Maximal Minimal Allowed Range
{n,m} {n,m}?

Must occur at least n times but no more than m times

{n,} {n,}?

Must occur at least n times

{n} {n}?

Must match exactly n times

* *?

0 or more times (same as {0,})

+ +?

1 or more times (same as {1,})

? ??

0 or 1 time (same as {0,1})

 
Code Matches
\a Alarm (beep)
\n Newline
\r Carriage return
\t Tab
\f Formfeed
\e Escape
\d A digit, same as [0-9]
\D A nondigit
\w A word character (alphanumeric), same as [a-zA-Z_0-9]
\W A nonword character
\s A whitespace character, same as [ \t\n\r\f]
\S A non-whitespace character
 
Modifier Meaning
g Match globally, that is, find all occurrences.
i Do case-insensitive pattern matching.
m Treat string as multiple lines. (continued)
o Only compile pattern once.
s Treat string as single line.
x Use extended regular expressions.
 
Modifier Meaning
e Evaluate the right side as an expression.
g Replace globally, that is, all occurrences.
i Do case-insensitive pattern matching.
m Treat string as multiple lines.
o Only compile pattern once.
s Treat string as single line.
x Use extended regular expressions.
 
Modifier Meaning
c Complement the SEARCHLIST.
d Delete found but unreplaced characters.
s Squash duplicate replaced characters.
相关阅读 更多 +
排行榜 更多 +
枪战特训2

枪战特训2

飞行射击 下载
方块枪战战场安卓版

方块枪战战场安卓版

飞行射击 下载
战斗火力射击安卓版

战斗火力射击安卓版

飞行射击 下载