作者nash7555 (Caspar)
看板Perl
标题Re: [请益] 删除特殊字串, 保留其它内容
时间Sat Apr 18 23:06:46 2020
※ 引述《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)
--
It always seems impossible until it's done.
事情尚未完成前,一切总看似不可能。
Nelson Mandela
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 223.137.246.134 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Perl/M.1587222410.A.CAB.html
1F:→ LiloHuang: ($line_temp = $line) =~ s/^\(\d+\)//; 应该就可以了 04/18 23:07