为了节省时间,我制作了这个小脚本来检查运动结果:
然而,Padre抱怨syntax error at line 7 near "+>"
在各种正则表达式网站上进行测试时,它的效果非常出色。 我错过了什么?
#!/usr/bin/perl
use LWP::Simple;
my $url = "https://svenskaspel.se/?pageid=/resultat/topptipset";
my $content = get($url);
$content = (\d{1}.+/-/.+).*?([/1X2/]{1});
print ("Match $1 Resultat: $2");
干杯
答案 0 :(得分:1)
在检查提供的链接后,我怀疑你想要这个:
# sample line 4 AZ Alkmaar - PSV Eindhoven 2 2 - 4
# |\_________________________/\______/|\/\___/
# | | | / \ |
# | | | / \ |
# (1) (2) (3) (4) (5)(6)
$content =~ /(\d+.+)[ ]+([1X2])[ ]+\d+\s*[-]\*\d+/;
# explanation ^ ^ ^ ^ ^ ^
# (1) (2)(3) (4) (5) (6)
# | | | | | +---- context: matching this portion together with (3)-(5) limits the greedy match of the team names.
# | | | | +-------- context
# | | | +-------------- result code
# | | +------------------- context (no trailing spaces in the capture group representing teams)
# | +---------------------- teams w/o leading and trailing spaces
# +-------------------------- id of the tournament match