您的位置:首页 > 其它

Match Any Character (匹配任意字符)

2014-03-28 10:25 148 查看
1. 需求

1.1 匹配任意非(line break)字符

1.1.1. Tcl

a. Reg

.

b. Code

if [regexp -linestop {.} $subject] {

# Successful match

} else {

# Match attempt failed

}

1.1.2 Python

a. Reg

.

b. Code

if re.search(".", subject):

# Successful match

else:

# Match attempt failed

1.2 匹配任意字符 (包含line speak)

1.2.1. Tcl

a. Reg

(?s).

b.Code

if [regexp -linestop {(?s).} $subject] {

# Successful match

} else {

# Match attempt failed

}

or

if [regexp {.} $subject] {

# Successful match

} else {

# Match attempt failed

}

1.1.2 Python

a. Reg

(?s).

b. Code

if re.search("(?s).", subject):

# Successful match

else:

# Match attempt failed

or

if re.search(".", subject, re.DOTALL):

# Successful match

else:

# Match attempt failed
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: