Chinaunix
标题:
正则水平挑战
[打印本页]
作者:
x95527
时间:
2016-04-28 22:11
标题:
正则水平挑战
分享一个正则水平测试工具,有兴趣的可以试试。 通关了记得分享下答案
play.inginf.units.it
(只爬到level6)
作者:
hz_oracle
时间:
2016-04-29 13:02
页面好卡。很慢
作者:
wh7211
时间:
2016-04-30 19:18
本帖最后由 wh7211 于 2016-05-03 21:50 编辑
回复
1#
x95527
play.inginf.units.it
level#1:[0-9]+
level#2:([a-z0-9]{2}:){5}[a-z0-9]{2}
level#3:ftp:[^ ]*
level#4:\$[^$]*\$ 或 \$.*?\$
level#5:([0-9]{1,3}\.){3}[0-9]{1,3}
level#6:href=("[^"]*"|'[^']*')
level#7:http:([=.]*[^ >=.]+){1,} 或 http:[^> ]*[^=> .]
level#8:<h[1-5].*
level#9:\(*(734|800)\)*[ ./-][0-9]{3}[-.][0-9]{4}
level#10:[a-zA-Z-]*, +[a-zA-Z"\\{']*( [A-Z][a-zA-Z]*|}[a-z]+|)
level#11:(?<=<h[0-9]>).*(?=</h[0-9]>) 『此网站不支持(?<=exp),所以另一种写法:( *<span|<a|in [56]|Strumenti|Contents).*(?=</h)』
level#12:(?<=[0-9]. )[a-zA-Z]+, +[A-Z]\.([A-Z].|) 『此网站不支持(?<=exp)』
复制代码
作者:
ace_fei
时间:
2016-05-03 10:07
本帖最后由 ace_fei 于 2016-05-03 10:51 编辑
6. href=(['"]).*?\1
7. \b(?!.*com\.|.*\w=(?!\w))http://[^>\s]+|http:.*\&start|http:.*com
8. <h(\d).*</h\1>
9. \(?(734|800)\)?\s*[\d-\/.]+\b
10. [a-zA-Z-]+,.+?(?=\sand|},)
11. (\s*<(span|a).*</(span|a)>\s*|in\s.*|[^>]+)(?=</h)
12. (?<=\d\.\s)\w+,\s+[A-Z.]+ 这题不用(?<=)搞不定,求指教。
作者:
ace_fei
时间:
2016-05-03 10:15
wh7211 发表于 2016-04-30 19:18
回复 1# x95527
play.inginf.units.it
7题好精炼的正则,能解释下么?
作者:
wh7211
时间:
2016-05-03 20:54
回复
5#
ace_fei
有2条记录的结尾是『.』和『=』,题目要求不匹配那两条记录最后的『.』和『=』,因此要在前面加上『[=.]*』。
作者:
liion631818
时间:
2016-05-04 10:26
回复
1#
x95527
[0-9]+
([a-zA-Z0-9]+:){5}[a-zA-Z0-9]+
ftp://ftp[^ ]+
\$(\\)*[a-zA-Z]+(_)*[^$]*\$
([0-9]+\.){3}[0-9]+
href="[^"]+"|href='[^']+'
http://[^ >]+
<h[1-5].*>(<span .+>)*.*(</span>)*</h[1-5]>
([\(]*[0-9]+[\)]*[ /])*\b[0-9]{3}[.-][0-9]+([.-][0-9]+)*\b
( *<span|<a|in [56]|Strumenti|Contents).*(?=</h[1-9])
(?<=[0-9]. )[A-Z][a-zA-Z]+, [A-Z].([A-Z].)*
复制代码
作者:
ace_fei
时间:
2016-05-05 17:15
本帖最后由 ace_fei 于 2016-05-05 17:21 编辑
回复
6#
wh7211
哦,试了下([
/
]*[^ >
/
]+)+,还真的就排除了最后的
/
字符,有意思。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2