我正在寻找一个在Perl中执行此操作的解决方案.
示例:如果我的字符串是:
my $content = 'toto /app/blah titi\nhuh/app/ttt wew';
Run Code Online (Sandbox Code Playgroud)
我的模式是:/app/something我想在数组中得到输出:/app/blah和/app/ttt.
(这基本上是grep -E -o '\/app\/[a-z]*'做什么的)
我做不到!我试过了:
my $content = 'toto /app/blah titi\nhuh/app/ttt wew';
$content =~ m/(\/app\/[a-z]*)/;
print "Group: $1 $2\n";
Run Code Online (Sandbox Code Playgroud)
但这只打印:( /app/blah不是/app/ttt)
无论如何,我不知道如何将结果放在表格中:
my (@table) = @_;
Run Code Online (Sandbox Code Playgroud)
该表不包含任何内容!
谢谢