How to take part of the string

1 view (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 2 Sep 2017
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')

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!