基本知识

 

(1)Matching any character:.
. matches any character(任何字符,包含 space与 _), alphabetic characters(文字字符), digits(数字字符), and even . itself ( .本身) 
 
The (?s) flag turns on "dot all" mode, allowing the dot character to match anything, including end-of-line characters. It is useful if you are matching patterns that span multiple lines. The s stands for "single-line mode," a somewhat confusing name derived from Perl.
 
 
如果不是使用 (?s) 模式
 
 
.是不匹配 end-of-line characters 字符的!
 
 

(2)Matching Whitespace or nonwhitespace character: /s, /S

Table 4.4. Whitespace Metacharacters

Metacharacter

Description

/s

Any whitespace character (same as [/f/n/r/t/v])

/S

Any nonwhitespace character (same as [^/f/n/r/t/v])

Note:[/b], the backspace metacharacter, is not included in /s or excluded by /S.

 

(3)Matching  Digits

Digit Metacharacters

Metacharacter

Description

/d

Any digit (same as [0-9])

/D

Any nondigit (same as [^0-9])

(4)Matching  Alphanumeric characters

Table 4.3. Alphanumeric Metacharacters

Metacharacter

Description

/w

Any alphanumeric character in upper- or lower-case and underscore (same as [a-zA-Z0-9_])

/W

Any nonalphanumeric or underscore character (same as [^a-zA-Z0-9_])

 
Note:Whitespace Metacharacters
Table 4.1. Whitespace Metacharacters

Metacharacter

Description

[/b]

Backspace

/f

Form feed

/n

Line feed

/r

Carriage return

/t

Tab

/v

Vertical tab

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值