正则表达式在线网站–regex101.com
body {background-color : #fefbd8;
}h1 {background-color : #0000ff;
}div {background-color : #d0f4e6;
}span {background-color : #f08970;
}
Re: (?<=#)[0-9a-fA-F]{6}
或#([0-9a-fA-F]{6})
(?<=)
代表look behind,{m, n}
代表有m到n个字符,{m}
代表恰好有m个字符,{m,}
代表至少匹配m个字符
3/8/23
3-8-2023
2/2/2
03-08-2023
Re: \d{1,2}[-\/]\d{1,2}[-\/]\d{2,4}
(简单版,不能排除00的情况 (0[1-9]|1[0-2])
)
\d equals [0-9],\/
匹配斜杠
1001: $496.80
1002: $1290.89
1003: $26.43
1004: 613.42
1005: 7.61
1006: $414.90
1007: $25.00
Re: \$\d{3,}\.\d{2}
$
和.
需要加上\
表示raw
The cat scattered his food all over the room.
Re: \bcat\b
\b
代表一个boundary,一侧是word character,另一侧不是
Welcome to my Homepage
Content is divided into two sections:
SQL
Information about SQL.RegEx
Information about Regular Expressions.This is not a valid HTML
Re: <([hH][1-6])>.*?<\/\1>
.*?
表示非贪婪匹配,因为.
可以表示除\n
外的任何字符(不同engine上可能不同)
\1
可以匹配前面第一个括起来的内容,同理,\2
表示第二个括号中的内容
拓展资料:
《正则表达式必知必会》