【发布时间】:2013-12-02 16:39:49
【问题描述】:
我能够根据您的建议成功提取所有内容。我的问题如预期的那样出现,正则表达式没有正确识别某些东西......非常感谢!这是我的结束代码...希望对某人有所帮助!
if($_=~/(Research Interests)/){
$research = "Research Interest";
if($_=~m/<h2>Research Interests<\/h2>(.*?)<p>(.*?)<\/p>/gs){
@researchInterests = split(/,+/, $2);
$count = 1;
foreach(@researchInterests){
print "$research $count:";
print $_. "\n";
$count++;
}
}
}
【问题讨论】:
-
不幸的是我要使用正则表达式进行解析...
-
告诉你的老师你不应该使用正则表达式来解析 HTML。对于您的任务,您或许应该考虑是否可以真正将
<h2>Research Interests</h2>^M之类的字符串与正则表达式/<p>.*</p>/匹配。 -
把你的老师引向这个:stackoverflow.com/questions/1732348/…——然后找出你为什么不明白为什么这是一个非常不正确的教育习惯。
-
"这是我的结束代码...希望对某人有所帮助!"当您删除问题后,它将如何帮助任何人?