Regex 正则表达式正在工作,但仍然不工作
为了节省时间,我制作了这个小脚本来检查运动成绩: 然而,Padre抱怨第7行“+>”附近出现语法错误。 当在不同的regex站点上测试它时,它工作得非常出色。 我错过了什么Regex 正则表达式正在工作,但仍然不工作,regex,perl,Regex,Perl,为了节省时间,我制作了这个小脚本来检查运动成绩: 然而,Padre抱怨第7行“+>”附近出现语法错误。 当在不同的regex站点上测试它时,它工作得非常出色。 我错过了什么 #!/usr/bin/perl use LWP::Simple; my $url = "https://svenskaspel.se/?pageid=/resultat/topptipset"; my $content = get($url); $content = (\d{1}.+/-/.+).*?([/1X2/]{1
#!/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");
干杯检查提供的链接后,我怀疑您想要此链接:
# 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
正则表达式分隔符在哪里<代码>$content~/(\d{1}.+\/-\/.+).*([\/1X2\/]{1})/代码>$content=~/(\d{1}.+/-/.+).*([/1X2/]{1})/<代码>它工作得很好。你确定吗?您想匹配什么?谢谢您的输入。使用代码时返回空白:这是我的代码,你看到问题了吗?很明显吗/usr/bin/perl使用LWP::Simple;我的$url=“”;我的$content=get($url)$content=~/(\d++)[]+([1X2])[]+\d++\s*[-]*\d++;印刷品(1美元、2美元、3美元、4美元、5美元、6美元);您需要以pplain文本表示的web页面,而不需要html标记