公告
财富商城
积分规则
提问
发文
2019-06-14 07:54发布
傲
The final output should only be 1368083 numbers in a column
Use sed to extract the digit part between two '_',
sed
sed 's/^.*_\([0-9]*\)_.*/\1/'
Or use awk to extract the 2nd field separated by '_',
awk
awk -F'_' '{print $2}'
Use str.split
str.split
s1 = "Row1_1368083_US_PBPR_STD" s2 ="Row215_1368083_US_PBPR_ENH" print(s1.split("_")[1]) print(s2.split("_")[1])
Output:
1368083 1368083
Or Regex.
import re s1 = "Row216_60902413_US_PBPR_ENH" s2 ="Row227_37758281_US_PBPR_ENH" print(re.findall(r"\d{6,}", s1)[0]) print(re.findall(r"\d{6,}", s2)[0])
awk -F_ '$2 ~/1368083/{print $2}' file 1368083 1368083
最多设置5个标签!
Use
sed
to extract the digit part between two '_',Or use
awk
to extract the 2nd field separated by '_',Use
str.split
Output:
Or Regex.