我有一个变量,里面有一些文本
$foo = "
Garbage directory
/test/this/is/a/directory
/this/is/another/foo\nThisd is is\nDrop stuff testing\nRandom stuff emacs is great";
我如何使用正则表达式来获取行/test/this/is/a/directory
我试过这个:
my $foo = "
Garbage directory
/test/this/is/a/directory
/this/is/another/foo\nThisd is is\nDrop stuff testing\nRandom stuff emacs is great";
$foo =~ /^\/test.*$/;
print "\n$foo\n";
但这只是继续打印整个文本块。