How to take part of the string

1 回表示 (過去 30 日間)
Mekala balaji
Mekala balaji 2017 年 9 月 2 日
回答済み: Walter Roberson 2017 年 9 月 2 日
Hi,
I have the following cell array.
STB.VD02K500E3T00
STB.VD06K13E3T20
VD02K150E3T00
Detail03
Dummay03
STB.VG02K500E5T00
STB.F02K500E0T00
PR_STB.F02K500E3T00
Now, I want to take the part of numerical just left&right side to the E including E if the name starts with STB., My desired output:
500E3
13E3
150E3
Detail03
Dummay03
500E5
500E0
PR_STB.F02K500E3T00

採用された回答

Walter Roberson
Walter Roberson 2017 年 9 月 2 日
result = regexprep(YourCell, '^(STB|V).*?(\d+E\d+).*', '$2');
I used the rule from your "desired output", not the rule from your description: your desired output extracts the number from a string that starts with V but your description says only if it starts with STB. If the rule is to be STB only and the transformation of the V line was in error then
result = regexprep(YourCell, '^STB.*?(\d+E\d+).*', '$1')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by