correctly split with multiple under score
Afficher commentaires plus anciens
I have a cell array with several underscore. I was wondering how to correctly split the string when you have underscores. My input looks like this:
(a) MK_0334_300151IT0005274805/MD_01082027_3_103 I want only 300151IT0005274805
(b) MK_0334_700720ES01653860_1_103 . I want only 700720ES01653860_1
© CAB001_0578_SK09 1100 0000 i want SK09 1100 0000.
(d) CR_07_C_59163230 i want only C_5916323
i have tried to split the data using : regexp({my_data}, '_', 'split'); then selecting the cell 3 and then split it using
regexp({cell 3}, '/MD', 'split');. however, that doensn't work for (b) and (d) data type.
4 commentaires
Dyuman Joshi
le 5 Jan 2023
The results you want don't have uniform logic. Are you expecting a single logic for all 4 options?
Sheikh Omar Bah
le 5 Jan 2023
the cyclist
le 5 Jan 2023
The hard part is not writing the MATLAB code. The hard part is understanding what single "rule" or logic is that results in what you want.
Tell us the rule.
Adam Danz
le 5 Jan 2023
To illustrate what others have mentioned above, explain why you don't want to return "SK09 1100" in your 3rd example or why you don't want to return "07" in your 4th example?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!