Cross-posted at Perlmonks如何提取某個單詞之後的數據?
$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: $'"
}
}
這份打印的整個字符串。我使用了$'函數,但它花費了太多的數據。我如何限制它?
如果我只打印「昨天和之後」,該怎麼辦?我將如何能夠開始在中間匹配腳本?
你應該能夠增加這個老問題來滿足你的需要:http://stackoverflow.com/questions/11084106/how-to-copy-a-pattern-from-a-string-variable-in-perl/11084290#11084290 – PinkElephantsOnParade
'昨天和那天'你究竟在做什麼? – sln