password
type
Last edited time
Aug 11, 2023 04:01 AM
status
slug
summary
tags
category
Created time
Aug 10, 2023 10:23 AM
icon
符号
描述
示例
有效匹配
无效匹配
^
字符串或行的开头
^foam
foam
bath foam
\A
任何匹配模式下的字符串开头
\Afoam
foam
bath foam
$
字符串或行的末尾
finish$
finish
finnish
\Z
字符串结尾,或任何匹配模式下最后一个新行之前的字符
finish\Z
finish
finnish
\z
字符串结尾,在任何匹配模式下。
\G
上一个匹配的结尾或第一个匹配的字符串的开头
^(get|set)|\G\w+$
setValue
seValue
\b
字边界;单词字符 (\w) 和非单词字符 (\W) 之间的位置
\bis\b
This island is beautiful
This island isn't beautiful
\B
非字边界
\Bland
island
peninsula
符号
描述
示例
有效匹配
无效匹配
(?=...)
positive lookahead
question(?=s)
questions
question
(?!...)
negative lookahead
answer(?!s)
answer
answers
(?<=...)
positive look-behind
(?<=appl)e
apple
application
(?<!...)
negative look-behind
(?<!goo)d
mood
good
符号
描述
示例
有效匹配
无效匹配
[ ]
class definition
[axf]
a, x, f
b
[ - ]
class definition range
[a-c]
a, b, c
d
[ \ ]
escape inside class
[a-f.]
a, b, .
g
[^ ]
Not in class
[^abc]
d, e
a
[:class:]
POSIX class
[:alpha:]
string
0101
.
match any chars except new line
b.ttle
battle, bottle
bttle
\s
white space, [\n\r\f\t ]
good\smorning
good morning
good.morning
\S
no-white space, [^\n\r\f\t]
good\Smorning
good.morning
good morning
\d
digit
\d{2}
23
1a
\D
non-digit
\D{3}
foo, bar
fo1
\w
word, [a-z-A-Z0-9_]
\w{4}
v411
v4.1
\W
non word, [^a-z-A-Z0-9_]
.$%?
.$%?
.ab?
符号
描述
\
general escape
\n
new line
\r
carriage return
\t
tab
\v
vertical tab
\f
form feed
\a
alarm
[\b]
backspace
\e
escape
\cchar
Ctrl + char(ie:\cc is Ctrl+c)
\ooo
three digit octal (ie: \123)
\xhh
one or two digit hexadecimal (ie: \x10)
\x{hex}
any hexadecimal code (ie: \x{1234})
\p{xx}
char with unicode property (ie: \p{Arabic}
\P{xx}
char without unicode property
符号
描述
示例
有效匹配
无效匹配
|
alternation
apple|orange
apple, orange
melon
( )
subpattern
foot(er|ball)
footer or football
footpath
(?P<name>...)
subpattern, and capture submatch into name
(?P<greeting>hello)
hello
hallo
(?:...)
subpattern, but does not capture submatch
(?:hello)
hello
hallo
+
one or more quantifier
ye+ah
yeah, yeeeah
yah
*
zero or more quantifier
ye*ah
yeeah, yeeeah, yah
yeh
?
zero or one quantifier
yes?
yes, ye
yess
??
zero or one, as few times as possible (lazy)
yea??h
yeah
yeaah
+?
one or more lazy
/<.+?>/g
<P>foo</P> matches only <P> and </P>
*?
zero or more, lazy
/<.*?>/g
<html>
{n}
n times exactly
fo{2}
foo
fooo
{n,m}
from n to m times
go{2,3}d
good,goood
gooood
{n,}
at least n times
go{2,}
goo, gooo
go
(?(condition)...)
if-then pattern
(<)?[p](?(1)>)
<p>, p
<p
(?(condition)...|...)
if-then-else pattern
^(?(?=q)que|ans)
question, answer
quote
模式
描述
g
全局匹配
i
不区分大小写,同时匹配大写和小写
m
多行
s
单行(默认)
x
忽略空白允许注释
A
锚定后,图案被迫^
D
仅美元结尾,美元元字符仅在末尾匹配
S
执行额外的分析,对于非锚定模式有用
U
不贪婪的、贪婪的模式默认会变得懒惰
X
PCRE 的附加功能(PCRE extra)
J
允许子模式重复名称
u
unicode、模式和主题字符串被视为 UTF-8
Linux基本操作解决python-pptx报错问题