1
我們有以下的語法文件:需要幫助的正則表達式
I/P : abc_com.an.gx3d_02-20-2014_05-26-38.txt
O/P : abc_com.an.gx3d
我試圖消除與時間戳開始的部分。我試着用下面的代碼,但它不工作:
(my $test = $file) =~ s/^\d{2}\.*//;
我們有以下的語法文件:需要幫助的正則表達式
I/P : abc_com.an.gx3d_02-20-2014_05-26-38.txt
O/P : abc_com.an.gx3d
我試圖消除與時間戳開始的部分。我試着用下面的代碼,但它不工作:
(my $test = $file) =~ s/^\d{2}\.*//;
你的^錨迫使你的正則表達式匹配只在字符串的開頭。你可能想要更接近以下的東西:
(my $test = $file) =~ s/_\d{2}-\d{2}-\d{4}_.*//;