[問題] 如何取得()內不定長度的字串
大家好
小弟最近在練習ㄧ個題目
將.lib裡面的cell 取出來
並且依照cell名稱另存新檔
目前,已經可以成功的取出來
但是名稱上面依舊有著(),我只想保留裡面的名稱
例如
cell (FADDS1), 我只想要取出FADDS1而不要有()
但是每個名稱不見得ㄧ樣長度
不知道各位大大,有沒有好的想法可以建議ㄧ下
謝謝
open(open_file, "12.txt") or "error file!!";
my $Out;
my $name;
while (<open_file>)
{
if ($_=~ m/^cell/g)
{
if ($_=~ /\s(.*\b.)/)
{
$name=$1;
open(write_file, ">$name.txt") or "error file!!";
}
print $_;
print write_file $_;
$Skip= 1;
next;
}
if ($Skip==1)
{
$Out .=$_;
print $_;
print write_file $_;
}
if ($_=~ m/^}/g)
{
$Skip=0;
next;
close write_file;
}
}
close open_file;my $Skip;
######---------12.txt---------######
library(std_ff) {
/*general attributes */
delay_molel : table_lookup;
in_palce_swap_mode : match_footprint;
cell (DFADDS1) {
cell_footprint : addf;
area : 126.7200;
pin(A) {
direction : input;
capacitance : 0.00975;
}
pin(B) {
direction : inoutput;
capacitance : 0.1975;
}
pin(CI) {
direction : utput;
capacitance : 0.1980;
}
}
cell (DFADDS2) {
cell_footprint : addf;
area : 126.7200;
pin(A) {
direction : input;
capacitance : 0.88975;
}
pin(B) {
direction : inoutput;
capacitance : 0.1900;
}
pin(CI) {
direction : utput;
capacitance : 0.1080;
}
}
cell (DFADDS2) {
cell_footprint : addf;
area : 126.7200;
pin(A) {
direction : input;
capacitance : 0.88975;
}
pin(B) {
direction : inoutput;
capacitance : 0.1900;
}
pin(CI) {
direction : utput;
capacitance : 0.1080;
}
}
cell (DFADDS4) {
cell_footprint : addf;
area : 126.7200;
pin(A) {
direction : input;
capacitance : 0.86975;
}
pin(B) {
direction : inoutput;
capacitance : 0.1902;
}
pin(CI) {
direction : utput;
capacitance : 0.0080;
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.176.59
→
05/02 00:06, , 1F
05/02 00:06, 1F
→
05/02 09:27, , 2F
05/02 09:27, 2F
→
05/02 19:31, , 3F
05/02 19:31, 3F
→
05/02 19:43, , 4F
05/02 19:43, 4F
→
05/03 09:09, , 5F
05/03 09:09, 5F
→
05/03 14:46, , 6F
05/03 14:46, 6F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Perl 近期熱門文章
PTT數位生活區 即時熱門文章