How to take part of the string

2 次查看(过去 30 天)
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 个)

Community Treasure Hunt

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

Start Hunting!

Translated by