入力perlで
[security] [client 198.66.91.7] [domain testphp.example.com] [200] [/apache/20160503/20160503-0636/[email protected]] (null)
所望の出力
/apache/20160503/20160503-0636/[email protected]
は、ここで私はこれまで
'.*?\[.*?\].*?\[.*?\].*?\[.*?\].*?\[.*?\].*?\[(.*?)\]'
私のPerlコードが持っているものです。
#!/usr/bin/perl
use feature 'say';
$txt='[modsecurity] [client 199.66.91.7] [domain testphp.vulnweb.com] [200] [/apache/20160503/20160503-0636/[email protected]] (null)';
$re=''.*?\[.*?\].*?\[.*?\].*?\[.*?\].*?\[.*?\].*?\[(.*?)\]'';
if ($txt =~ m/$re/is)
{
$sbraces1=$1;
say $1;
}
出力
/apache/20160503/20160503-0636/[email protected]
私は私の正規表現は厄介だと思いますか?多分別の方法ですか?
おかげ
分割アプローチを使用する必要があります。 –
あなたのコメントは答えがあります – Deano
@Deano私は答えを追加しました。 – AKS