【发布时间】:2012-06-20 18:51:58
【问题描述】:
$String = "hello I went to the store yesterday and the day after and the day after";
我只想打印单词i went to the store。我尝试了两种方法,都没有成功:
if ($String =~ /hello/i) {
until ($String =~ /yesterday/i) {
print "Summary: $'"
}
}
这打印了整个字符串。我使用了 $' 函数,但它占用了太多数据。如何限制?
如果我只想打印“昨天和后天”怎么办?我如何才能开始匹配中间的脚本?
【问题讨论】:
-
您应该能够扩充这个旧问题以满足您的需求:stackoverflow.com/questions/11084106/…
-
yesterday and the day after你到底想做什么?
标签: regex perl regex-greedy