How to take part of the string
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Mekala balaji
il 2 Set 2017
Risposto: Walter Roberson
il 2 Set 2017
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
0 Commenti
Risposta accettata
Walter Roberson
il 2 Set 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')
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!