我想從字符串中提取值(它會不斷變化)以供進一步處理。如何從perl中更改字符串中提取值
該字符串是
TPSM seed 4339CD65 pass 1 x 0 x 1 errors 0 pid 179947 rulefilecycle 0
TPSM seed 5339CD60 pass 1 x 9 x 2 errors 0 pid 179947 rulefilecycle 0
TPSM seed 2339CD61 pass 1 x 101 x 5 errors 0 pid 179947 rulefilecycle 0
TPSM seed 5339CD65 pass 1 x 19 x 6 errors 0 pid 179947 rulefilecycle 0
TPSM seed 9339CD65 pass 1 x 100 x 7 errors 0 pid 179947 rulefilecycle 0
我想後的形式1×一個X Ñ,其中i有興趣在 'n' 的值通提取值。 我試圖在perl中使用substr(),但由於數字不斷變化,我不能寫一些像substr($ string,37,1)這樣的東西。
我怎麼能達到這個沒有substr()以某種正則表達式的方式?
這工作,我需要弄清楚這是什麼命令,我的意思是這似乎是正則表達式,TQ – hanish
可以簡化爲'/通(?:\ S + \ d + \ S + x)的{2} \ S +(\ d +)/'採取進階重複圖案 – Sundeep
@Sundeep的:沒錯,相應地編輯。 – Toto