Re: [請益] 刪除特殊字串, 保留其它內容

作者: nash7555 (Caspar)   2020-04-18 23:06:46
※ 引述《nash7555 (Caspar)》之銘言:
: 各位高手, 先進
: perl regexp小弟搞半天還是不太能掌握
: 如下行內容 - ($line)
: (582): truncated value with size 8 to match size of target (7)
: 想變成 - ($line_temp)
: : truncated value with size 8 to match size of target (7)
: 該如何撰寫code
: 基本上想刪除的內容是括號內任意0~9數字, 位元數不一定
: 想留下的內容是括號後面的(可能包含大小字母, 數字和特別符號)
: 萬分感謝~
目前只研究到這裡
print $string_temp."\n" if ($string_temp =~ /^\([0-9]+\):\s+.*$/);
顯示如下:
(7006): actual bit length 16 differs from formal bit length 13 for port
"cfgbp_link2csr"
(120): truncated value with size 64 to match size of target (32)
(144): truncated value with size 64 to match size of target (32)
(241): truncated value with size 5 to match size of target (4)
但是砍掉就還不知道怎麼做...
期望是:
: actual bit length 16 differs from formal bit length 13 for port
"cfgbp_link2csr"
: truncated value with size 64 to match size of target (32)
: truncated value with size 64 to match size of target (32)
: truncated value with size 5 to match size of target (4)
作者: LiloHuang (十年一刻)   2020-04-18 23:07:00
($line_temp = $line) =~ s/^\(\d+\)//; 應該就可以了

Links booklink

Contact Us: admin [ a t ] ucptt.com