不確定最好的方式做到這一點,但我可以使用任何bash/awk/sed/perl/...來做這件事嗎?格式化字符串從X到Y +
簡要說明
我希望能夠藉此
(Intra TAU success Times(SGW not change) + Intra TAU success Times(SGW change) + Period TAU success Times(SGW not change)+ Period TAU success Times(SGW change))/(Intra TAU request Times(SGW not change) + Intra TAU request Times(SGW change)+ Period TAU request Times(SGW not change)+ Period TAU request Times(SGW change)) x 100%
,並格式化這個
([Intra TAU success Times(SGW not change)]+[Intra TAU success Times(SGW change)]+[Period TAU success Times(SGW not change)]+[Period TAU success Times(SGW change)])/([Intra TAU request Times(SGW not change)]+[Intra TAU request Times(SGW change)]+[Period TAU request Times(SGW not change)]+[Period TAU request Times(SGW change)])*100
詳細說明
我希望能夠藉此格式(這將是一個線,僅僅指剛提出這樣的清晰度)
(
Intra TAU success Times(SGW not change) +
Intra TAU success Times(SGW change) +
Period TAU success Times(SGW not change)+
Period TAU success Times(SGW change)
)/(
Intra TAU request Times(SGW not change) +
Intra TAU request Times(SGW change)+
Period TAU request Times(SGW not change)+
Period TAU request Times(SGW change)
)
x 100%
,併產生這種格式:
(
[Intra TAU success Times(SGW not change)]+
[Intra TAU success Times(SGW change)]+
[Period TAU success Times(SGW not change)]+
[Period TAU success Times(SGW change)]
)/(
[Intra TAU request Times(SGW not change)]+
[Intra TAU request Times(SGW change)]+
[Period TAU request Times(SGW not change)]+
[Period TAU request Times(SGW change)]
)
*100
什麼我想要做
1加方括號[]
所有櫃檯
藉此串Intra TAU success Times(SGW not change)
和產生這種[Intra TAU success Times(SGW not change)]
注意並非所有計數器字符串將在)
2結束與*
3更換x
刪除%
如果不是所有的字符串以')結尾,那麼其他可能性是什麼? – hwnd
要考慮的一種策略是將輸入按其語義表達,將其解析爲結構,然後以新格式輸出,而不是將其視爲可塑文本。 – DavidO
@hwnd它可能有一些像這樣的'Period TAU請求時間'與這個'Period TAU請求時間(SGW更改)'相對應,因此它基本上可以是[az] – HattrickNZ